Ver Mensaje Individual
  #40  
Antiguo 30-04-2010
Avatar de sierraja
sierraja sierraja is offline
Miembro
 
Registrado: sep 2004
Posts: 281
Reputación: 22
sierraja Va por buen camino
Wink

Buenos dias,

Revise los triggers y no encontre nada que me diera indicios de lo que comenta guillotmarc, pero de todas maneras le hice un seguimiento a cada evento relacionado. Luego de realizar las pruebas con condiciones del where, hizo la actualizacion pero solamente filtrando la data unicamente con tarifas, mes y year a la vez y ejecutando el proceso directamente desde ib-expert:

Lo ejecute varias veces para las demas tarifas y los demas meses:


Código SQL [-]
execute procedure act_impuesto_1("Residencial","Consumo",9,2009)
execute procedure act_impuesto_1("Residencial","Consumo",1,2010)
execute procedure act_impuesto_1("Residencial","Consumo",2,2010)
execute procedure act_impuesto_1("Especial","Consumo",9,2009)
execute procedure act_impuesto_1("Especiall","Consumo",1,2010)
execute procedure act_impuesto_1("Especial","Consumo",2,2010)


El procedimiento ejecutado es:

Código SQL [-]
SET TERM ^ ;
CREATE PROCEDURE ACT_IMPUESTO_1 (
    X_TIPO_TARIFA VARCHAR(30),
    X_TIPO_FACTURA VARCHAR(10),
    X_MES INTEGER,
    X_YEAR INTEGER)
AS
begin
  update facturacion
  set base_imponible = cloaca, excento=0
  where tipo_tarifa=:x_tipo_tarifa and tipo_factura=:x_tipo_factura and extract(month from fecha)=:x_mes and extract(year from fecha)=:x_year;
  suspend;
end^
SET TERM ; ^
GRANT SELECT,UPDATE ON FACTURACION TO PROCEDURE ACT_IMPUESTO_1;
GRANT EXECUTE ON PROCEDURE ACT_IMPUESTO_1 TO SYSDBA;

Y para el resto de las tarifas se aplico lo siguiente:


[sql]execute procedure act_impuesto_2("Comercial","Consumo",9,2009)
execute procedure act_impuesto_2("Comercial","Consumo",1,2010)
execute procedure act_impuesto_2("Comercial","Consumo",2,2010)
execute procedure act_impuesto_2("Industrial A","Consumo",9,2009)
execute procedure act_impuesto_2("Industrial A","Consumo",1,2010)
execute procedure act_impuesto_2("Industrial A","Consumo",2,2010)
/SQL El procedimiento ejecutado es:
Código SQL [-]
SET TERM ^ ;
CREATE PROCEDURE ACT_IMPUESTO_2 (
    X_TIPO_TARIFA VARCHAR(30),
    X_TIPO_FACTURA VARCHAR(10),
    X_MES INTEGER,
    X_YEAR INTEGER)
AS
begin
  update facturacion
  set base_imponible = cargo_fijo + cargo_exceso_consumo + cargo_variable + cloaca, excento=0
  where tipo_tarifa=:x_tipo_tarifa and tipo_factura=:x_tipo_factura and extract(month from fecha)=:x_mes and extract(year from fecha)=:x_year;
  suspend;
end^
SET TERM ; ^
GRANT SELECT,UPDATE ON FACTURACION TO PROCEDURE ACT_IMPUESTO_2;
GRANT EXECUTE ON PROCEDURE ACT_IMPUESTO_2 TO SYSDBA;





Hasta llegar con todas las tarifas y en los ultimos tres meses. De esta manera fue que pude actualziar. Se ve ilogico, pero trate de hacer un solo SP pero no realizaba nada pero de todas maneras expogo el SP:


Código SQL [-]
SET TERM ^ ;
CREATE PROCEDURE ACT_IMPUESTO (
    X_TIPO_TARIFA VARCHAR(30),
    X_TIPO_FACTURA VARCHAR(10),
    X_MES INTEGER,
    X_YEAR INTEGER)
AS
begin
  if (x_tipo_tarifa='Residencial') then
    update facturacion
    set base_imponible = cloaca, excento=0
    where tipo_factura=:x_tipo_factura and extract(month from fecha)=:x_mes and extract(year from fecha)=:x_year;
  if (x_tipo_tarifa='Especial') then
    update facturacion
    set base_imponible = cloaca, excento=0
    where tipo_factura=:x_tipo_factura and extract(month from fecha)=:x_mes and extract(year from fecha)=:x_year;
  if (x_tipo_tarifa='Comercial') then
    update facturacion
    set base_imponible = cargo_fijo + cargo_exceso_consumo + cargo_variable + cloaca, excento=0
    where tipo_factura=:x_tipo_factura and extract(month from fecha)=:x_mes and extract(year from fecha)=:x_year;
  if (x_tipo_tarifa='Industrial A') then
    update facturacion
    set base_imponible = cargo_fijo + cargo_exceso_consumo + cargo_variable + cloaca, excento=0
    where tipo_factura=:x_tipo_factura and extract(month from fecha)=:x_mes and extract(year from fecha)=:x_year;
  if (x_tipo_tarifa='Industrial B') then
    update facturacion
    set base_imponible = cargo_fijo + cargo_exceso_consumo + cargo_variable + cloaca, excento=0
    where tipo_factura=:x_tipo_factura and extract(month from fecha)=:x_mes and extract(year from fecha)=:x_year;
end^
SET TERM ; ^
GRANT SELECT,UPDATE ON FACTURACION TO PROCEDURE ACT_IMPUESTO;
GRANT EXECUTE ON PROCEDURE ACT_IMPUESTO TO SYSDBA;



Este procedimiento no funcionada. Pero como dije antes realizaba prueba modificando el filtro del where y por separado funcionaba y fue de esta manera que pude resolver la situacion. En el futuro no vamos a tener este problema, ya que al crear el registro vamos a tener en cuenta todos los campos y no va a ser necesario actualizarlos luego.

De todas maneras seria bueno las observaciones para con los SP para en un futuro no volver a caer en estos detalles.

Caballeros muchas gracias por su colaboracion y por el aporte de sus valiosisimos conocimientos. Muchas gracias
Responder Con Cita