Using SQL Code activity

Avatar

Avatar
Give Back 5
Level 3
marcinkacz
Level 3

Likes

19 likes

Total Posts

46 posts

Correct reply

2 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile

Avatar
Give Back 5
Level 3
marcinkacz
Level 3

Likes

19 likes

Total Posts

46 posts

Correct reply

2 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile
marcinkacz
Level 3

17-07-2020

Hi,
How I can use the output of SQL Code activity in a following JS activity?

 

sqlCodeActivityWkf.PNG

I'm typing below code in SQL activity:
SELECT max(iId) FROM CusTestDataSchema

 

What should I type in JS to receive SQL's output? vars.output doesn't work here.

 

Thanks,

Marcin

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

125 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

125 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile
_Manoj_Kumar
MVP

21-07-2020

Hello @marcinkacz ,

 

Instead of writing a SQL code and then use the output in javascript code, The right approach would be to use queryDef javascript function in javascript code activity and pull the data.

 

Here are the links for some documentations on how to use the queryDef function in javascript:

https://docs.adobe.com/content/help/en/campaign-classic/using/configuring-campaign-classic/api/data-...

https://blog.floriancourgey.com/2018/08/use-querydef-the-database-toolkit-in-adobe-campaign

 

Thanks,

Answers (1)

Answers (1)

Avatar

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

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

Avatar
Establish
MVP
wodnicki
MVP

Likes

977 likes

Total Posts

1,096 posts

Correct reply

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

21-07-2020

Hi,

 

Use queryDef where possible, otherwise use a js activity with sqlGet* or the DBEngine class.

 

E.g.:

var cnx = application.getConnection();
try {
  var res = cnx.query('select sysdate from dual');
  for each (var row in res) logInfo(row[0]);
}
finally {
  cnx.dispose();
}

 

Thanks,

-Jon