I confirm (used the following code):
#include %systemInclude
n
try{
s sql="select * from (select 0 field union select 1) where 0=1"
#dim rs As %SQL.StatementResult=##class(%SQL.Statement).%ExecDirect(,sql)
w rs.%SQLCODE
s st = ##class(%SQL.Statement).%New()
$$$ThrowOnError(st.%Prepare(sql))
s rs = st.%Execute()
w !,"---",!,rs.%SQLCODE
&sql(select * from (select 0 field union select 1) where 0=1)
w !,"---",!,SQLCODE
}catch(ex){
w "Error ", ex.DisplayString(),!
}
Output:
0
---
0
---
100
Quote from the documentation:
When retrieving results, first check for successful execution by examining %SQLCODE. For many statement types, success/failure is all that is needed. The %SQLCODE property contains the SQL error code value. Successful completion values are 0 (successful completion) and 100 (the operation has either found no data or reached the end of the data).proof
- Log in to post comments