Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Using SQL Code activity

marcinkacz
Level 4
Level 4

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

1 Accepted Solution
Manoj_Kumar_
Correct answer by
Community Advisor
Community Advisor

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,

View solution in original post

3 Replies
Manoj_Kumar_
Correct answer by
Community Advisor
Community Advisor

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,

View solution in original post

wodnicki
Community Advisor
Community Advisor

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

marcinkacz
Level 4
Level 4

As always thank you for your help. But I'm not asking how to use query. I'm interested in SQL Code activity and its output.