Stored Procedure
am 15.06.2006 21:15:49 von Melissa Dougherty------=_NextPart_000_0055_01C6908E.95B37640
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I'm still new to the MySQL SPs.... Does anyone see a problem with this =
code?
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`test_AuditRun_SP`$$
CREATE PROCEDURE `test`.`test_AuditRun_SP`(OUT OblDocNo varchar(50), OUT =
OBLCNT INT)
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE Obldoctype varchar(10);
DECLARE Obldocno varchar(50);
DECLARE Oblrefdocno varchar(50);
DECLARE Obldollamt varchar(50);
DECLARE Recdoctype varchar(10);
DECLARE Recdocno varchar(50);
DECLARE Recrefdocno varchar(50);
DECLARE Recdollamt varchar(50);
DECLARE curObl1 CURSOR FOR SELECT =
doc_type,doc_no,ref_doc_no,concat('-',gv_dollar_amt) FROM =
test.ar_no_ins_outs_temp WHERE doc_type in ('PV','GV');
DECLARE curRec2 CURSOR FOR SELECT =
doc_type,doc_no,ref_doc_no,gv_dollar_amt FROM test.ar_no_ins_outs_temp =
WHERE doc_type in ('RG','RC','RT');
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done =3D 1;
=20
OPEN curObl1;
OPEN curRec2;
REPEAT
FETCH curObl1 INTO Obldoctype, Obldocno, Oblrefdocno, Obldollamt;
FETCH curRec2 INTO Recdoctype, Recdocno, Recrefdocno, Recdollamt;
IF NOT done THEN
IF obldocno =3D recdocno and Oblrefdocno =3D Recrefdocno and =
Obldollamt =3D Recdollamt THEN
INSERT into ar_no_ins_outs_delete =
(doc_type,doc_no,ref_doc_no,gv_dollar_amt)
values (Obldoctype, Obldocno, Oblrefdocno, Obldollamt);
END IF;
END IF;
=20
UNTIL done END REPEAT;
CLOSE curObl1;
CLOSE curRec2;
END$$
DELIMITER ;
Thanks,
Melissa
------=_NextPart_000_0055_01C6908E.95B37640--