MySQL Forums
Forum List  »  Spanish

Declaracion de variables en Procedimiento Almacenado
Posted by: Luis Lujan
Date: June 13, 2016 10:46AM

Buenos días amigos... Por favor una ayuda: estoy iniciando una migracion desde MSSQL a MySQL y estoy encontrado algunos problemas. En este procedimiento almacenado me salta un error en el primer comando DECLARE del primer IF. No sé que esta faltando. El mensaje es:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare ccodlprecio space(6) default space(6) declare ncodlprecio int default ' at line 12

Gracias de antemano por su ayuda.


drop procedure if exists usp_upd_precios_cab;

delimiter //

create procedure usp_upd_precios_cab (
in cidlprecio char(6),
in cdsclprecios varchar(100),
in cmoneda char(1),
in ffdesde datetime,
in ffasta datetime,
in cidcreador varchar(30),
in cmanto char(1))

begin
if cmanto='N' then
declare ccodlprecio space(6) default space(6)
declare ncodlprecio int default 0

select ccodlprecio=ifnull(max(idlprecio),'000000') from precios_cab
select ncodlprecio=cast(ccodlprecio as int)
select ncodlprecio=ncodlprecio+1
select ccodlprecio=cast(ncodlprecio as varchar(6))

select ccodlprecio=right('000000'+cast(ccodlprecio as varchar(6)),6)
select cidlprecio=ccodlprecio

insert into precios_cab
(idlprecio,dsclprecios,moneda,fdesde,fhasta,idcreador) values
(cidlprecio,cdsclprecios,cmoneda,ffdesde,ffhasta,cidcreador)

select ccodlprecio idlprecio;
end if;

if cmanto='M' then
update
precios_cab
set
dsclprecios=cdsclprecios,
moneda=cmoneda,
fdesde=ffdesde,
fhasta=ffhasta,
idactualiza=cidcreador,
factualiza=CURRENT_TIMESTAMP
where
idlprecio=cidlprecio
end if;
end //

Options: ReplyQuote


Subject
Views
Written By
Posted
Declaracion de variables en Procedimiento Almacenado
12771
June 13, 2016 10:46AM


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.