Using SQL Code activity | Community
Skip to main content
marcinkacz
Level 3
Jul 17, 2020 10:20 AM UTC
Solved

Using SQL Code activity

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

 

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
_Manoj_Kumar_
_Manoj_Kumar_Accepted solution
New Participant
Jul 21, 2020 4:08 PM UTC

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-oriented-apis.html

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

 

Thanks,

     Manoj     Find me on LinkedIn

3 replies

Jonathon_wodnicki
New Participant
Jul 22, 2020 5:05 AM UTC

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

Translate
marcinkacz
Level 3
Jul 22, 2020 8:29 AM UTC

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.

Translate
_Manoj_Kumar_
_Manoj_Kumar_Accepted solution
New Participant
Jul 21, 2020 4:08 PM UTC

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-oriented-apis.html

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

 

Thanks,

Translate
     Manoj     Find me on LinkedIn