How to read and save data from SQL code activity

Avatar

Avatar

Abhishek_Kumar_Keshri

Avatar

Abhishek_Kumar_Keshri

Abhishek_Kumar_Keshri

04-02-2021

Hi,

 

I try query def in js but  JS code giving an error

Need JS to read and save output coming from below SQL.

 

Workflow ImageWhatsApp Image 2021-02-04 at 10.10.19.jpeg:-

 

SQL code activity contains:-

SELECT relname,

last_vacuum,
FROM pg_stat_all_tables

WHERE schemaname = 'common'

ORDER BY last_vacuum DESC;

 

Thanks & Regards 

Abhishek Keshri

 

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

saikatk2447661

Avatar

saikatk2447661

saikatk2447661

10-02-2021

Hi @Abhishek_Kumar_Keshri ,

 

Sql code activity does not create temp table so you can not read the result of select statement in this way. Delete the sql code activity and just use query function in js block and run it in js activity. You can read the content of any table in the database this way.

 

https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/m-DBEngine-query.html...

 

Thanks,

Saikat

Answers (1)

Answers (1)

Avatar

Avatar

craigthonis

Employee

Avatar

craigthonis

Employee

craigthonis
Employee

04-02-2021

Hi Abhishek,

 

Using the querydef is the correct approach.  Can you provide us with the error that you were seeing with the JS code along with the code itself?

 

Regards,

Craig