jueves, 19 de mayo de 2011

insert into Cuenta values(1,1,1000)
insert into Cliente values(1)
insert into LineaCredito values(1,1,500)
select * from cuenta
select * from lineacredito

Update Cuenta
Set
Saldo = 1000
where Idcuenta= 1;

select trigger_name
from user_triggers;


insert into Giro values(5,1,'01/01/22',2000)

Create or Replace Trigger trTransaccion
Before insert on Giro
For each row
Begin
Update Cuenta
Set
Saldo = Saldo - :new.Monto
where Idcuenta= :new.IdCuenta;
End trTransaccion;

Drop trigger trTransaccion ;


Create or Replace Trigger trMerma
Before insert on Giro
For each row
DECLARE
Vsaldo cuenta.saldo%type;
Vlimite lineacredito.saldo%type;
Descuento lineacredito.saldo%type;
Begin

Select saldo into Vsaldo
From Cuenta
Where IdCuenta= :new.IdCuenta;

Select saldo into Vlimite
From LineaCredito
Where IdCuenta= :new.IdCuenta;


if Vsaldo+Vlimite <= :new.monto then
vSaldo := :new.monto;
Else
dbms_output.put_line('No Alcanza el Saldo Disponible');
End if;
Update Cuenta
Set Saldo = Saldo - :new.Monto
where Idcuenta= :new.IdCuenta;

End trMerma;

No hay comentarios.:

Publicar un comentario