CREATE VIEW BUFFER_buffer-name
|
CREATE VIEW BUFFER_pcust_orders AS SELECT customer.custnum,
customer.name, order.ordernum FROM customer, order WHERE 1 = 0 |
CREATE VIEW BUFFER_pcust_states AS SELECT customer.custnum, state.state
FROM customer, state WHERE 1 = 0 |
DEFINE VARIABLE cSelect AS CHARACTER NO-UNDO.
DEFINE VARIABLE iHandle1 AS INTEGER NO-UNDO. DEFINE VARIABLE iHandle2 AS INTEGER NO-UNDO. DEFINE BUFFER bfCustomer FOR customer. RUN STORED-PROC send-sql-statement iHandle1 = PROC-HANDLE ("SELECT custnum, state FROM customer"). FOR EACH bfCustomer WHERE PROC-HANDLE = iHandle1: cSelect = "SELECT state, statename, region FROM state WHERE state = '" + bfCustomer.state + "'". RUN STORED-PROC send-sql-statement iHandle2 = PROC-HANDLE (cSelect). FOR EACH bfCustomer WHERE PROC-HANDLE = iHandle2: DISPLAY bfCustomer. END. CLOSE STORED-PROC send-sql-statement WHERE PROC-HANDLE = iHandle2. END. CLOSE STORED-PROC send-sql-statement WHERE PROC-HANDLE = iHandle1. |
/* First part of example - Stored procedure code */
create or replace package cv_types as type GenericCurType is ref cursor; End cv_types; /CREATE or replace PROCEDURE pcustorder (num IN INT, c1 out cv_types. GenericCurType, c2 out cv_types.GenericCurType) AS BEGIN IF num IS NULL THEN raise_application_error (-20101, ‘Cust Num is missing'); ELSE open c1 for SELECT cust_num,name FROM customer WHERE cust_num > num; open c2 for SELECT order_num,odate FROM order_WHERE order_.Cust_num > num; END IF; END; / |
/* Second part of example - ABL procedure code*/
DEFINE VARIABLE hProc AS HANDLE NO-UNDO. RUN STORED-PROC pcustorder (INPUT 10, OUTPUT 10, OUTPUT 10, OUTPUT 10, OUTPUT 10). FOR EACH pcust_buffer WHERE PROC-HANDLE = hProc AND CURSOR = pcustorder.c1: DISPLAY pcust_buffer. END. FOR EACH porder_buffer WHERE PROC-HANDLE = hProc AND CURSOR = pcustorder.c2: DISPLAY porder_buffer. END. CLOSE STORED-PROC pcustorder. |