triggers - Inserted, Deleted tables in postgreSQL, like SQL Server? -
i want create trigger after inserted event, need data inserted in order register new table trigger in postgresql
in sql server capture these values inserted
or deleted
pseudo tables these tables exists in postgresql? or can do?
this trigger code
create trigger tri_compago after insert on matricula each row execute procedure fn_inscomppago(); create or replace function fn_inscomppago() returns trigger $body$ declare begin insert compromisopago(codigotasa,descripcion,precio,fechavencimiento,codigomatricula) select codigotasa,descripcion,precio,fechavencimiento,i.codigo programacionpago pp join inserted on isnull(i.codigoconvenio,0) = isnull (pp.codigoconvenio,0) , pp.codigopresentacion = i.codigopresentacion pp.vigencia = 1 , i.vigencia = 1; return null; end; $body$ language plpgsql volatile cost 100; alter function fn_inscomppago() owner postgres;
i have no idea how triggers work in sql server in postgresql, use old
, new
special variables:
new
data typerecord
; variable holding new database rowinsert
/update
operations in row-level triggers. variablenull
in statement-level triggers ,delete
operations.
old
data typerecord
; variable holding old database rowupdate
/delete
operations in row-level triggers. variablenull
in statement-level triggers ,insert
operations.
so want @ new.codigo
, new.codigoconvenio
, new.codigopresentacion
, , new.vigencia
in case. you'd replace i.vigencia = 1
part of clause simple if i.vigencia = 1
conditional well.
Comments
Post a Comment