Noob with SPL
CONNECT supports a variable name. But I wonder if that is only when within a HLL.
I cannot get a CONNECT TO within SPL to support either a column name or a variable.
The create or replace works.
Call fails with
[SQL0950] Relational database V_SYSTEM_NAME not in relational database directory
Which leads me to believe that it thinks it is neither a variable nor column name but the actual database name.
Do I need to prefix the variable or column like I do with embedded sql? If so, what?
CREATE or replace PROCEDURE BACKUP_STATUS
LANGUAGE SQL MODIFIES SQL DATA
P1: BEGIN
DECLARE COMMAND CHAR(200); -- Ensure this is large enough.
DECLARE V_SYSTEM_NAME CHAR(25);
FOR V1 AS
C1 CURSOR FOR
select x.* from table(
values('RACK1HST'), ('GDWEB'), ('GDIHQ1'), ('GDISYS1'), ('MAIL1'),
('RACK2HST'), ('GDWEB2'), ('GDIHQ2'), ('GDISYS2'), ('MAILTWO'),
('RACK3HST'), ('MAIL3'), ('GDI'), ('DOMTEST'), ('MAIL4')) as x (SYSTEM_NAME)
DO
SET V_SYSTEM_NAME = SYSTEM_NAME;
connect to v_system_name;
-- do some stuff there
disconnect v_system_name;
set command = 'SNDMSG MSG(' CONCAT system_name CONCAT ') TOUSR(ROB)';
CALL QSYS2.QCMDEXC(COMMAND);
END FOR;
END P1
;
CALL BACKUP_STATUS;
Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
As an Amazon Associate we earn from qualifying purchases.