Ver Mensaje Individual
  #2  
Antiguo 23-11-2007
Avatar de jhonny
jhonny jhonny is offline
Jhonny Suárez
 
Registrado: may 2003
Ubicación: Colombia
Posts: 7.058
Reputación: 30
jhonny Va camino a la famajhonny Va camino a la fama
Puedes crear lo que tienes en un procedimiento almacenado, asi:
Código SQL [-]
CREATE PROCEDURE SP_DFACTURA_IN (
    codigo integer,
    precio integer)
as
declare variable v_pro_precio double precision;
begin
  select Pro_precio from Producto where Pro_Codigo=:Codigo
  into :v_pro_precio;

  if (:v_pro_precio < :Precio) then
  Begin
    Update Producto Set Pro_Precio=:Precio
    Where Producto.Pro_Codigo = :Codigo;
  End
end

Y un Trigger en la tabla DFACTURA que ejecute dicho procedimiento, asi:

Código SQL [-]
CREATE trigger trigg_dfactura_in for dfactura
active after insert position 0
AS
begin
  execute procedure SP_DFACTURA_IN(Pro_Codigo, DFa_Precio);
end


Espero te sirva .
__________________
Lecciones de mi Madre. Tema: modificación del comportamiento, "Pará de actuar como tu padre!"

http://www.purodelphi.com/
http://www.nosolodelphi.com/

Última edición por jhonny fecha: 23-11-2007 a las 20:38:57.
Responder Con Cita