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
BedrockMission!

Learn More

View all

Sign in to view all badges

How to read and save data from SQL code activity

Avatar

Avatar
Validate 1
Level 1
Abhishek_Kumar_Keshri
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
Abhishek_Kumar_Keshri
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

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

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
Contributor
Level 3
saikatk2447661
Level 3

Likes

22 likes

Total Posts

57 posts

Correct Reply

14 solutions
Top badges earned
Contributor
Shape 1
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Contributor
Level 3
saikatk2447661
Level 3

Likes

22 likes

Total Posts

57 posts

Correct Reply

14 solutions
Top badges earned
Contributor
Shape 1
Give Back 5
Give Back 3
Give Back
View profile
saikatk2447661
Level 3

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
Give Back 10
Employee
craigthonis
Employee

Likes

167 likes

Total Posts

258 posts

Correct Reply

152 solutions
Top badges earned
Give Back 10
Give Back 5
Give Back 3
Give Back
Boost 50
View profile

Avatar
Give Back 10
Employee
craigthonis
Employee

Likes

167 likes

Total Posts

258 posts

Correct Reply

152 solutions
Top badges earned
Give Back 10
Give Back 5
Give Back 3
Give Back
Boost 50
View profile
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