Final Hints
If you're outputing query records as part of your debug routine, it is sometimes easier to limit the query results to just a few records, particularly when encoding the output as JSON. You can limit any query objects results by using the "setMaxRows()" method and passing the desired number of rows (e.g. queryObj.setMaxRows(1))
If you need to know that exact SQL that was submitted as part of a successful query, you can use the getPrefix() function to output a structure (note that this is a complex object and should be outputed like the other complex objets referenced above using the savecontent method). For example, queryObj.execute().getPrefix() will return a structure with the SQL command, record count, SQL parameters (if any), etc. for the associated query object.
If you need to know that exact SQL that was submitted as part of an unsuccessful query, you can use error trapping via a try/catch setup. The catch portion should be written as "catch (any e) {}". You can then get the exact SQL command issued by output the e.sql string. Likewise, e.message and e.detail will have the specifics of the error that was caught by the catch condition.
Last updated
Was this helpful?