- Código: Seleccionar todo
- delimiter //
- CREATE PROCEDURE `administra_nova`.`sp_Actualiza_Interes` (registro int)
- BEGIN
- DECLARE interes1, interes2 int;
- DECLARE interes3, resultado int;
- select ninteresjdh,ninteresfdh
- into interes1,interes2
- from ttcontrollicita
- where nlicitacion_id=registro;
- select ninteresptp into interes3
- from ttcontrollicita
- where nlicitacion_id=registro;
- if interes1=0 and intres2=0 and interes3=0 then
- update ttcontrollicita set NInteresGen=0 where NLicitacion_id=registro;
- else
- if interes1>0 and interes2=0 and intres3=0 then
- update ttcontrollicita set NInteresGen=interes1 where NLicitacion_id=registro;
- else
- if interes1=0 and interes2>0 and intres3=0 then
- resultado=(interes1 + interes2 + interes2)/3;
- update ttcontrollicita set NInteresGen=interes2 where NLicitacion_id=registro;
- else
- if interes1=0 and interes2=0 and intres3>0 then
- resultado=(interes1 + interes2 + interes2)/3;
- update ttcontrollicita set NInteresGen=interes3 where NLicitacion_id=registro;
- else
- if interes1>0 and interes2>0 and intres3=0 then
- resultado=(interes1 + interes2)/2;
- update ttcontrollicita set NInteresGen=resultado where NLicitacion_id=registro;
- else
- if interes1>0 and interes2=0 and intres3>0 then
- resultado=(interes1 + interes3)/2;
- update ttcontrollicita set NInteresGen=resultado where NLicitacion_id=registro;
- else
- if interes1=0 and interes2>0 and intres3>0 then
- resultado=(interes2 + interes3)/2;
- update ttcontrollicita set NInteresGen=resultado where NLicitacion_id=registro;
- else
- if interes1>0 and interes2>0 and intres3>0 then
- resultado=(interes1 + interes2 + interes3)/3;
- update ttcontrollicita set NInteresGen=resultado where NLicitacion_id=registro;
- end if;
- end if;
- end if;
- end if;
- end if;
- end if;
- end if;
- end if;
- END;
- delimiter;
Pero al momento de querer correrlo, para que sea guardado en la b.d. me manda el siguiente mensaje:
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 interes3, resultado int;
select ninteresjdh,ninteresfdh
into interes' at line 1
(16 ms taken)
Ya estuve revisando varios manuales de MYSQL pero sinceramente ya me desespere y no encuentro lo que necesito, quisiera ver si me pueden ayudar.
Gracias.





