MySQL Forums
Forum List  »  Stored Procedures

procedure with if
Posted by: Ale Diaz Velasquez
Date: April 17, 2019 02:06PM

I have this procedure, but it doesn´t work, anybody could help me please

DELIMITER $$
CREATE PROCEDURE guardarConbp()
BEGIN
declare v_numcc varchar(6);
declare v_rutprov varchar(10);
declare v_serie VARCHAR(3);
declare v_fecha DATE;
declare v_monto int;
declare v_numcheq int;
declare v_nummov int;
declare v_numfact VARCHAR(9);
declare getConbp int DEFAULT 0;
declare cursor_conbp cursor for select CONBP_NUMEROCC, CONBP_RUTPROV, CONBP_SERIE, CONBP_FECHA, CONBP_MONTO, CONBP_NUMCHEQ, CONBP_NUMMOV, CONBP_NUMFAC from tbl_conbp where `CONBP_MONTO` != 0;
declare continue handler for not found set getConbp=1;
open cursor_conbp;
getConbp : LOOP FETCH
cursor_conbp INTO v_numcc, v_rutprov, v_serie, v_fecha, v_monto, v_numcheq, v_nummov, v_numfact;
if getConbp = 1 then
leave getConbp;
end if;
if(cursor_conbp)
INSERT INTO reg_conbp(`NEW_CONBP_NUMEROCC`, `NEW_CONBP_RUTPROV`, `NEW_CONBP_SERIE`, `NEW_CONBP_FECHA`, `NEW_CONBP_MONTO`, `NEW_CONBP_NUMCHEQ`, `NEW_CONBP_NUMMOV`, `NEW_CONBP_NUMFAC`) VALUES( v_numcc, v_rutprov, v_serie, v_fecha, v_monto, v_numcheq, v_nummov, v_numfact);
ELSE
ALTER TABLE reg_conbp add NEW_CONBP_FECHA date, NEW_CONBP_MONTO integer;
UPDATE reg_conbp SET NEW_CONBP_FECHA = v_fecha and NEW_CONBP_MONTO = v_monto WHERE NEW_CONBP_RUTPROV = v_rutprov
end if;
end loop getConbp;
close cursor_conbp;


END; $$

DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
procedure with if
1210
April 17, 2019 02:06PM
433
April 18, 2019 09:33AM
461
April 18, 2019 12:35PM
406
April 18, 2019 01:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.