Doesn't sound logical to me. That would be the equivalent (?) in the mainframe world of doing a declare and open cursor without doing the first fetch. Until you've done the fetch, you have no data. As to the no match etc, here's an example of the code I have
result = odbcsetconnectopt("TXN|UNCOMMIT")
DO
odbcexecute(data., "columns")
CATCH ERROR
err = CONDITION('D')
rc = show_db2_error.rex(err)
RETURN -1
END
table_row = 0
rc = 0
insert_limit = 10
IF db2.!count > 500 THEN
progress_limit = 200
ELSE
progress_limit = 25
db2_data.0 = 0
riidfr = ''
DO
DO UNTIL odbcfetch("data.", columns) = "DONE" | table_row > max_records | rc \= 0
END
and the show_db2_error.rex contains
PROCEDURE EXPOSE db2.
PARSE ARG result
temp = UNAME(-2)
temp = FILESPEC('N',temp)
PARSE VAR temp title '.' .
temp = WORDS(result)
cause = WORD(result, temp)
SELECT
WHEN cause = 'CANCEL' THEN
RETURN 1
WHEN POS('SQL30082N',result) <> 0 THEN
temp = "Cannot connect to "db2.source" - incorrect password ?"
WHEN (POS('SQL30081N',result) <> 0) & (POS('10061',result) <> 0) THEN
temp = "Cannot connect to "db2.source" - try rebooting your machine"
WHEN POS('IM002',result) <> 0 THEN
DO
temp = "Your PC has not been configured for ODBC connection to "db2.source" - investigate"
END
OTHERWISE
DO
err = REVERSE(result)
y = POS(']',err)
SELECT
WHEN y = 0 THEN
y = REVERSE(y)
OTHERWISE
err = SUBSTR(err,1,y-1)
END
temp = REVERSE(err)
END
END
temp = "DB2 Error:" || "0D0A"x || temp
rc = wdwsay.rex(temp, 'STOP', title)
RETURN 1
Does this answer your question ? (As to SQLCODE etc, as you can see from show_db2_error.rex, their "equivalents" are not available - to my knowledge - as such. The argument to show_db2_error.rex - result - is the equivalent of calling DSNTIAR on the mainframe, ie, a long error message) |