|
Readers with good memory may recall my earlier post describing myefforts to create an SQL procedure that uses 3-part file names to query
OUTMBR(*FIRST *REPLACE)');
-- Execute the query for each LPARS row
EXECUTE IMMEDIATE 'Connect to ' || v_LPSERVER ;
EXECUTE IMMEDIATE 'DROP TABLE DBALE/$DSPPRB';
CALL QCMDEXC ('DSPPRB OUTPUT(*OUTFILE) OUTFILE(DBALE/$DSPPRB)
EXECUTE IMMEDIATE 'Disconnect ALL' ;expected via fetching through the LPARS table. Sometimes the CONNECT TO
I watched through debug to ensure that v_LPSERVER is changing as
OUTMBR(*FIRST *REPLACE)');
Is CONNECT TO flaky or am I missing something?
In case anyone is interested, here is the procedure in full:
CREATE or REPLACE PROCEDURE dbale/DSPPRB_ALL()
modifies SQL data
not deterministic
language SQL
specific AC_DSPPRB
set option dbgview = *SOURCE
BEGIN
DECLARE v_LPSERVER VARCHAR(18);
DECLARE v_LPSEQUENCE INT;
DECLARE done INT DEFAULT 0;
DECLARE SQLstatement VARCHAR(1024);
-- Declare a cursor to fetch rows from the LPARS table
DECLARE c_LPARS CURSOR FOR
SELECT LPSERVER, LPSEQUENCE
FROM LPARS
order by LPSEQUENCE;
-- Declare a CONTINUE HANDLER for NOT FOUND condition
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET done = 1;
-- Declare a CONTINUE HANDLER for SQLEXCEPTION condition
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
Begin
DECLARE v_errormsg VARCHAR(70) not NULL Default '';
DECLARE v_sql_stmt VARCHAR(1000);
GET DIAGNOSTICS CONDITION 1 v_errormsg = MESSAGE_TEXT;
End;
-- Ensure there are no active connections
EXECUTE IMMEDIATE 'Disconnect ALL' ;
-- Open the cursor
OPEN c_LPARS;
-- Loop through the LPARS rows
read_loop: LOOP
FETCH c_LPARS INTO v_LPSERVER, v_LPSEQUENCE;
IF done = 1 THEN
LEAVE read_loop;
END IF;
set v_errormsg = '';
-- Execute the query for each LPARS row
EXECUTE IMMEDIATE 'Connect to ' || v_LPSERVER ;
EXECUTE IMMEDIATE 'DROP TABLE DBALE/$DSPPRB';
CALL QCMDEXC ('DSPPRB OUTPUT(*OUTFILE) OUTFILE(DBALE/$DSPPRB)
EXECUTE IMMEDIATE 'Disconnect ALL' ;communication may be confidential, and is intended only for the use of the
END LOOP;
-- Close the cursor
CLOSE c_LPARS;
END;
*** CONFIDENTIALITY NOTICE: The information contained in this
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.