Debugging sql statements that run within script as gliderecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2020 01:37 AM
Hi All,
There is a need to debug SQL statements that are executed within a scriptinclude / transform map's onbefore script for the purpose of facilating indexing via database.
However on node logs / debug sql during execution - the gliderecord classes used within script include and onbefore script are not getting displayed. Could you help here.
Example : lets say i have a bunch of gliderecord operations done on my SI and other scripts that must get displayed as SQL statement for facilitating DB team.
var gr = new GlideRecord("<table>");
gr.addQuery('<column>',par1);//added recent
gr.orderBy('usr');
gr.query();
while (gr.next()) {
//code
}
Thanks,
Iniya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-13-2020 01:44 AM
Hello Inya,
Instead of addQuery() can you try using addEncodedQuery() and then you can print the query with getEncodedQuery() where you are suppose to check/debug the data you getting in query.
BR
Nitesh
If my answer helped you in any way, mark answer as helpful and correct.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-15-2020 04:18 AM
Hello Iniya,
Go to session debug and enable all and check once. Check this link for more information.
Regards,
Asif

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-15-2020 04:41 AM
Hi Inya,
I would recommend use background Script module which you will find in System definition application run the script there first.
or else you can filter the record in list & copy the query from there & put in encoddedquery() method.
So this is two way by which you can debug your script or Sql Statement.
If the above code helps then please mark my answer Correct and Helpful.
Thanks and Regards:
Siddhnath Pandey