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 Image:-
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
Solved! Go to Solution.
Views
Replies
Total Likes
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.
Thanks,
Saikat
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
Views
Replies
Total Likes
Hi Craigthonis,
Here is the error which I am getting:-
.
Below is the JS code that I am using for the same
var query=xtk.queryDef.create(
<queryDef schema="temp:sql4" operation="select">
<select>
<node expr="@relname"/>
<node expr="@last_vacuum"/>
<node expr="@last_autovacuum"/>
<node expr="@last_analyze"/>
<node expr="@last_autoanalyze"/>
</select>
</queryDef>
);
var res = query.ExecuteQuery();
for each(var result in res){
logInfo(res.sql.@relname);
logInfo(res.sql.@last_vacuum);
logInfo(res.sql.@last_autovacuum);
logInfo(res.sql.@last_analyze)
logInfo(res.sql.@last_autoanalyze);
}
Thanks & Regards
Abhishek Keshri
Views
Replies
Total Likes
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.
Thanks,
Saikat
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies