Skip to content

How do I get SQL Error Details (Code, Text) of the executed Query in the test run

This example demonstrates how to capture the Error details(Code, Text) of the executed SQL Query.

In the solution shown below, the label name is given to the query using the "dbLabelQuery" command and is executed using the "dbExecuteQuery" command in the HICC application. The error details(code and text) if any are fetched using the "dbgetQueryExecutionErrorCode" and "dbgetQueryExecutionErrorText" commands.

Solution:

# Command Target Value
Start of a dbCONNECT Block
1 dbBlockOpen

To specify to Worksoft SaaS the "alias database" and "dbCONNECT tunnel" names
2 dbSetContext Worksoft SaaStrainingTunnel eureqa_postgres_ipc
To set the label name to the query
3 dbLabelQuery select zip.zipCode from eureqaref.Ref_US_Zipcode zip join eureqaref.Ref_US_State stat on stat.stateCode = zip.stateCode where lower(stat.stateName) = lower('California') GetZipcodes
To execute the DB Query
4 dbExecuteQuery GetZipcodes zipcodes
To retrieve the SQL Error code
5 dbgetQueryExecutionErrorCode GetZipcodes GetErrorCode
To retrieve the SQL Error Text
6 dbgetQueryExecutionErrorText GetZipcodes GetErrorText
End of a dbCONNECT Block
7 dbBlockEnd

Tips, Tricks, Gotchas & Best Practices:  

  • It is recommended to give a label name to the query using the "dbLabelQuery" command
  • It is a best practice to set the timeout before you execute a db query
  • The timeout specified is in seconds


Feedback and Knowledge Base