I want to make some procedures that can accept parms and will do simple embedded sql functions such as open and close a cursor, and fetch. I want to do this so I can clean up the way my code looks. Because SQL errors don't always cause a program to end when it should, I had to incorporate some kind of error handling. I'm using a service program that was writte to handle SQL errors; the procedure looks up the SQLCOD value and send the error text in a program break message. I then force the program to quit, which must be done from the mainline (as far as I know):
So what I want to do is create a procedure that can combine all of those functions. It will perform the cursor open, call CheckSQLErrors(), and exit the program if neccessary (if it's even possible to exit the program from within a procedure). I can see there being a problem with setting up the parms for the procedure that will accept the cursor name. Can you use passed-in values for a cursor in the open statement?
Code:
Exec sql Open Generic_Cursor;
If CheckSQLErrors();
*INLR = *ON;
return;
EndIf;
PCheckSQLErrors B
D PI N
/free
If SQLSTT <> '00000' and SQLSTT <> '02000';
RegExcpHandler('SQL0000':*ON:*OFF);
ThrowAndCatch ( SqlMsgid(SQLCOD): *OMIT: SQLERM );
return *on;
Else;
return *off;
EndIf;
/end-free
P E
So what I want to do is create a procedure that can combine all of those functions. It will perform the cursor open, call CheckSQLErrors(), and exit the program if neccessary (if it's even possible to exit the program from within a procedure). I can see there being a problem with setting up the parms for the procedure that will accept the cursor name. Can you use passed-in values for a cursor in the open statement?