How to add insert data which is populated from enrinchment?

Avatar

Avatar
Validate 1
Level 1
gowthamanrajendran
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
gowthamanrajendran
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
gowthamanrajendran
Level 1

07-02-2020

Hi, I have enrichment with all the data i want.

 

gowthamanrajendran_0-1581107546426.png

 

Now i am trying to insert into table through java script. I dont want to use update sql activity due to some table transformation.  How do i derive the data which populated in enrichment in java script. For ex

 

sqlExec("insert into gow:SampleDB(std_id,name) select std_id, name  from vars.targetSchema");

 

i want std_id and name from enrichment table.

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 3
Level 1
InderM
Level 1

Likes

3 likes

Total Posts

5 posts

Correct reply

1 solution
Top badges earned
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Boost 3
Level 1
InderM
Level 1

Likes

3 likes

Total Posts

5 posts

Correct reply

1 solution
Top badges earned
Boost 3
Boost 1
Affirm 1
View profile
InderM
Level 1

08-02-2020

Hi,

you can use queryDef  to fetch the data from targetSchema as shown below

 

var conditionVar="@age > 25";// example condition
var recordSet = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@std_id"/>
<node expr="@name"/>
</select>
<where>
<condition expr={conditionVar} />
</where>
</queryDef>
);

var allRecords = recordSet.ExecuteQuery();
for each (var rec in allRecords)

{
var var1=rec.std_id;

var var2=rec.name;

//your INSERT statement;
}

 

hope this helps.

Answers (1)

Answers (1)

Avatar

Avatar
Establish
MVP
wodnicki
MVP

Likes

976 likes

Total Posts

1,096 posts

Correct reply

514 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile

Avatar
Establish
MVP
wodnicki
MVP

Likes

976 likes

Total Posts

1,096 posts

Correct reply

514 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile
wodnicki
MVP

10-02-2020

Hi,

 

You can use an update db activity to update the db. Fetching and inserting a row at a time via the app server won't be efficient.

What's the transformation?

 

Thanks,

-Jon