DEFINE VARIABLE ix AS INTEGER NO-UNDO.
RUN STORED-PROC send-sql-statement NO-ERROR ("select count (*) from customer where name between a and 'z' "). /*Select statement syntax is incorrect due to type-mismatch*/ IF ERROR-STATUS:ERROR THEN DO: DO ix = 1 TO ERROR-STATUS:NUM-MESSAGES: MESSAGE "error" ERROR-STATUS:GET-NUMBER(ix) ERROR-STATUS:GET-MESSAGE(ix). END. RETURN. END. CLOSE STORED-PROC send-sql-statement. |
create or replace procedure sp_write_cust(
sp_cust_num in out number, sp_address in out varchar2 )as begin insert into customer(cust_num,address) values(sp_cust_num, sp_address); insert into customer(cust_num,address) values(sp_cust_num, sp_address); commit; /* Procedure accidently commits unique cust_num twice */ select cust_num, address into sp_cust_num, sp_address from customer where cust_num= sp_cust_num; end sp_write_cust; / |
DEF VAR intvar AS INTEGER.
DEF VAR ix AS INTEGER. DEF VAR num AS INTEGER. DEF VAR myaddr AS CHARACTER. num =1. myaddr = '21 Main Street'. RUN STORED-PROC sp_write_cust intvar = PROC-HANDLE (PARAM sp_cust_num = num, PARAM sp_address = myaddr). IF ERROR-STATUS:ERROR AND ERROR-STATUS:NUM-MESSAGES > 0 THEN DO: DO ix = 1 TO ERROR-STATUS:NUM-MESSAGES: MESSAGE ERROR-STATUS:GET-NUMBER(ix) ERROR-STATUS:GET-MESSAGE(ix). END. RETURN. END. CLOSE STORED-PROCEDURE sp_write_cust WHERE PROC-HANDLE = intvar. DISPLAY "Customer " + string(num) + " at address " + myaddr + " was added to the database". |
DEF VAR intvar AS INTEGER.
RUN STORED-PROC sp_img_out intvar = PROC-HANDLE (3, OUTPUT ?). CLOSE STORED-PROCEDURE sp_img_out WHERE PROC-HANDLE = intvar. /* This statement will not be executed on error */ CATCH eSysError AS Progress.Lang.ProError: MESSAGE eSysError:GetMessageNum(1) SKIP eSysError:GetMessage(1) SKIP eSysError:GetMessage(2) SKIP eSysError:GetMessage(3) VIEW-AS ALERT-BOX BUTTONS OK. /* Handler code for SysError condition. */ END. |
DEFINE VARIABLE tables AS HANDLE EXTENT 1 NO-UNDO.
RUN STORED-PROC send-sql-statement LOAD-RESULT-INTO tables NO-ERROR ("Invalid SQL Statement"). IF ERROR-STATUS:ERROR THEN MESSAGE ERROR-STATUS:GET-MESSAGE(1) VIEW-AS ALERT-BOX. ELSE MESSAGE "SQL call was successful." VIEW-AS ALERT-BOX. |