olbe
15-08-08, 15:27
Hi,
ich versuche mich gerade mal an Stored Procedures und hätte da jetzt ein "Problem" (oder eher einen unschönen Zustand).
Nachfolgend erst einmal die Stored Procedure:
CREATE PROCEDURE rlbo.cp1_get(IN com_partner CHAR(10), OUT tmp_last DECIMAL(9,0), OUT tmp_dir CHAR(30), OUT tmp_file_p CHAR(4), OUT err_flag CHAR(1))
LANGUAGE SQL
MODIFIES SQL DATA
BEGIN
DECLARE last_rec CHAR(1) DEFAULT 'N';
DECLARE tmp_low DECIMAL(9,0);
DECLARE tmp_high DECIMAL(9,0);
DECLARE cursor1 CURSOR FOR SELECT p1slow, p1shig, p1slas, p1hdir, p1fpri
FROM c82f.cp1
WHERE cp1mnd = 0 AND cp1id = 'P1' AND p1comp = com_partner AND p1kzsr = 'S';
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET last_rec = 'Y';
OPEN cursor1;
fetch_loop:
LOOP
FETCH cursor1 INTO tmp_low, tmp_high, tmp_last, tmp_dir, tmp_file_p;
IF last_rec = 'Y' THEN
LEAVE fetch_loop;
SET err_flag = 'Y';
ELSE
IF tmp_last >= tmp_high THEN
SET tmp_last = tmp_low;
END IF;
SET tmp_last = tmp_last + 1;
SET err_flag = 'N';
UPDATE c82f.cp1
SET p1slas = tmp_last
WHERE CURRENT OF cursor1;
END IF;
END LOOP fetch_loop;
CLOSE cursor1;
END
Aufruf im ILE-RPG:
/free
EXEC SQL CALL rlbo/cp1_get(:$i_c_com_part,
:$o_s_cp1_count,
:$o_c_cp1_path,
:$o_c_cp1_fpre,
:$o_c_cp1_err);
/end-free
Die Stored Procedure holt aus einer Zählertabelle (CP1) den letzen Stand des Zähler (+ weitere Parameter) , zählt diesen hoch, schreibt den aktuellen Wert in die Tabelle zurück und gibt verschiedene Werte an das aufrufende ILE-RPG zurück.
Mein Problem ist nun, daß ich sowohl in der Stored Procedure wie auch im ILE-RPG die Bibliothek fest hinterlegen muss, da ich ansonsten die SQL-Fehlermeldung 42704 (An undefined object or constraint name was detected) erhalte.
Gibt es eine Möglichkeit, das ganze ohne die fest definierten Bibliotheken zu lösen?
Vielen Dank.
ich versuche mich gerade mal an Stored Procedures und hätte da jetzt ein "Problem" (oder eher einen unschönen Zustand).
Nachfolgend erst einmal die Stored Procedure:
CREATE PROCEDURE rlbo.cp1_get(IN com_partner CHAR(10), OUT tmp_last DECIMAL(9,0), OUT tmp_dir CHAR(30), OUT tmp_file_p CHAR(4), OUT err_flag CHAR(1))
LANGUAGE SQL
MODIFIES SQL DATA
BEGIN
DECLARE last_rec CHAR(1) DEFAULT 'N';
DECLARE tmp_low DECIMAL(9,0);
DECLARE tmp_high DECIMAL(9,0);
DECLARE cursor1 CURSOR FOR SELECT p1slow, p1shig, p1slas, p1hdir, p1fpri
FROM c82f.cp1
WHERE cp1mnd = 0 AND cp1id = 'P1' AND p1comp = com_partner AND p1kzsr = 'S';
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET last_rec = 'Y';
OPEN cursor1;
fetch_loop:
LOOP
FETCH cursor1 INTO tmp_low, tmp_high, tmp_last, tmp_dir, tmp_file_p;
IF last_rec = 'Y' THEN
LEAVE fetch_loop;
SET err_flag = 'Y';
ELSE
IF tmp_last >= tmp_high THEN
SET tmp_last = tmp_low;
END IF;
SET tmp_last = tmp_last + 1;
SET err_flag = 'N';
UPDATE c82f.cp1
SET p1slas = tmp_last
WHERE CURRENT OF cursor1;
END IF;
END LOOP fetch_loop;
CLOSE cursor1;
END
Aufruf im ILE-RPG:
/free
EXEC SQL CALL rlbo/cp1_get(:$i_c_com_part,
:$o_s_cp1_count,
:$o_c_cp1_path,
:$o_c_cp1_fpre,
:$o_c_cp1_err);
/end-free
Die Stored Procedure holt aus einer Zählertabelle (CP1) den letzen Stand des Zähler (+ weitere Parameter) , zählt diesen hoch, schreibt den aktuellen Wert in die Tabelle zurück und gibt verschiedene Werte an das aufrufende ILE-RPG zurück.
Mein Problem ist nun, daß ich sowohl in der Stored Procedure wie auch im ILE-RPG die Bibliothek fest hinterlegen muss, da ich ansonsten die SQL-Fehlermeldung 42704 (An undefined object or constraint name was detected) erhalte.
Gibt es eine Möglichkeit, das ganze ohne die fest definierten Bibliotheken zu lösen?
Vielen Dank.