Esa es una forma de Crear Procedimientos en informix
drop procedure "a713ap00".upd_historia;
create procedure "a713ap00".upd_historia(aclave INTEGER,
arfc CHAR(13),
aname CHAR(70),
aingdt CHAR(8),
ainidesc INTEGER)
define aConsec integer ;
-- Busca que se haya dado de alta previamente el RFC
select max(fconsec) into aConsec from adhe_historia ;
-- Checa si encontro clave a asignar
if aConsec <= 0 then
let aConsec = 1 ;
else
let aConsec = aConsec + 1 ;
end if
-- Agrega nuevo registro al historial
insert into adhe_historia
(fconsec, fcveadhe, frfc, fnombre, ingdt, finidesc)
values(aconsec, aclave, arfc, aname, aingdt, ainidesc) ;
end procedure
-------------------TRIGGER
drop trigger upd_usuario_his;
create trigger upd_usuario_his
update on usuario referencing
old as adhe new as histo for each row
(
execute procedure upd_usuario_historia(adhe.idUsuario ,adhe.Usuario ,adhe.Pwd)
);
|