Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Firebird e Interbase (https://www.clubdelphi.com/foros/forumdisplay.php?f=19)
-   -   Correccion de Sintaxis (https://www.clubdelphi.com/foros/showthread.php?t=61174)

sierraja 28-10-2008 19:22:08

Correccion de Sintaxis
 
Buenas tardes, la verdad es que no genera ningun resultado, estoy utilizando D7 y Firebird 1.5, que podria estar escribiendo mal>



Código SQL [-]update facturacion set monto_iva=(cloaca*alicuota_iva)/100 where (tipo_factura='Consumo') and (Tipo_tarifa='Residencial' or tipo_tarifa='Especial' or tipo_tarifa='Gobierno') and (cloaca<>0) and (alicuota_iva<>0);
update facturacion set sub_total=consumo_agua+cloaca where (tipo_factura='Consumo') and (tipo_tarifa='Residencial' or tipo_tarifa='Especial');*/
update facturacion set (consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo) where (tipo_factura='Consumo') and (tipo_tarifa='Comercial') into sub_total;
update facturacion set sub_total=consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo where (tipo_factura='Consumo') and (tipo_tarifa='Industrial A');
update facturacion set sub_total=consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo where (tipo_factura='Consumo') and (tipo_tarifa='Industrial B');
update facturacion set monto_iva=(sub_total*alicuota_iva)/100 where (tipo_factura='Consumo') and (Tipo_tarifa='Comercial') and (alicuota_iva<>0);
update facturacion set monto_iva=(sub_total*alicuota_iva)/100 where (tipo_factura='Consumo') and (tipo_tarifa='Industrial A') and (alicuota_iva<>0);
update facturacion set monto_iva=(sub_total*alicuota_iva)/100 where (tipo_factura='Consumo') and (tipo_tarifa='Industrial B') and (alicuota_iva<>0);

boreg 28-10-2008 19:39:03

Prueba quitando el "*/" de la quinta linea e indicando que campo actualizarás en la 3era sentencia,

Código SQL [-]
update facturacion 
set (consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo)
where (tipo_factura='Consumo') and (tipo_tarifa='Comercial') into sub_total;

si utilizas un componente del tipo Query, creo que no es posible ejecutar mas de 1 sentencia con firebird (corrijanme si me equivoco), a menos que sea del tipo Script (no estoy seguro), así que trata de ejecutar 1 a la vez.

Por cierto, tambien recuerda ser mas preciso con tu pregunta/consulta al club, indica qué error te da, que componentes utilizas para la conexion con la base, que componente utilizas para ejecutar tus actualizaciones (Update), etc...

Saludos

BlueSteel 28-10-2008 19:40:15

en realidad como que no se entiende mucho... esto te da un error ??? en donde ??? cual es el error ??? desde donde lo ejecutas ???

ahh.. y creo que en forma ordenada se veria mucho mejor...
Código SQL [-]
UPDATE FACTURACION
SET    MONTO_IVA = (CLOACA * ALICUOTA_IVA) / 100
WHERE  (TIPO_FACTURA = 'Consumo')
       AND (TIPO_TARIFA = 'Residencial'
             OR TIPO_TARIFA = 'Especial'
             OR TIPO_TARIFA = 'Gobierno')
       AND (CLOACA <> 0)
       AND (ALICUOTA_IVA <> 0);

UPDATE FACTURACION
SET    SUB_TOTAL = CONSUMO_AGUA + CLOACA
WHERE  (TIPO_FACTURA = 'Consumo')
       AND (TIPO_TARIFA = 'Residencial'
             OR TIPO_TARIFA = 'Especial');

update facturacion set (consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo) where (tipo_factura='Consumo') and (tipo_tarifa='Comercial') into sub_total;

UPDATE FACTURACION
SET    SUB_TOTAL = CONSUMO_AGUA + CLOACA + CARGO_VARIABLE + CARGO_FIJO + CARGO_EXCESO_CONSUMO
WHERE  (TIPO_FACTURA = 'Consumo')
       AND (TIPO_TARIFA = 'Industrial A');

UPDATE FACTURACION
SET    SUB_TOTAL = CONSUMO_AGUA + CLOACA + CARGO_VARIABLE + CARGO_FIJO + CARGO_EXCESO_CONSUMO
WHERE  (TIPO_FACTURA = 'Consumo')
       AND (TIPO_TARIFA = 'Industrial B');

UPDATE FACTURACION
SET    MONTO_IVA = (SUB_TOTAL * ALICUOTA_IVA) / 100
WHERE  (TIPO_FACTURA = 'Consumo')
       AND (TIPO_TARIFA = 'Comercial')
       AND (ALICUOTA_IVA <> 0);

UPDATE FACTURACION
SET    MONTO_IVA = (SUB_TOTAL * ALICUOTA_IVA) / 100
WHERE  (TIPO_FACTURA = 'Consumo')
       AND (TIPO_TARIFA = 'Industrial A')
       AND (ALICUOTA_IVA <> 0);

UPDATE FACTURACION
SET    MONTO_IVA = (SUB_TOTAL * ALICUOTA_IVA) / 100
WHERE  (TIPO_FACTURA = 'Consumo')
       AND (TIPO_TARIFA = 'Industrial B')
       AND (ALICUOTA_IVA <> 0);

una vez ordenado esto... desde donde los estas ejecutando... todas en una sola sentencia ???

explica más tu problema

Salu2:p:D

sierraja 28-10-2008 20:14:10

Ok!, me falto indicarles que estas instrucciones las mando a ejecutar desde un procedimiento almacenado, y en realidad no generar ningun error, solo que no actualiza nada. Tambien voya a colocarleslos mas ordenado y con unos caracteres que se me fueron demas.:



Código SQL [-]
update facturacion set monto_iva=(cloaca*alicuota_iva)/100
where (tipo_factura='Consumo') and (Tipo_tarifa='Residencial' or tipo_tarifa='Especial' or tipo_tarifa='Gobierno') and (cloaca<>0) and (alicuota_iva<>0);
 
update facturacion set sub_total=consumo_agua+cloaca
where (tipo_factura='Consumo') and (tipo_tarifa='Residencial' or tipo_tarifa='Especial');
 
update facturacion set sub_total=consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo
where (tipo_factura='Consumo') and (tipo_tarifa='Comercial');
 
update facturacion set sub_total=consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo
where (tipo_factura='Consumo') and (tipo_tarifa='Industrial A');
 
update facturacion set sub_total=consumo_agua+cloaca+cargo_variable+cargo_fijo+cargo_exceso_consumo
where (tipo_factura='Consumo') and (tipo_tarifa='Industrial B');
 
update facturacion set monto_iva=(sub_total*alicuota_iva)/100
where (tipo_factura='Consumo') and (Tipo_tarifa='Comercial') and (alicuota_iva<>0);
 
update facturacion set monto_iva=(sub_total*alicuota_iva)/100
where (tipo_factura='Consumo') and (tipo_tarifa='Industrial A') and (alicuota_iva<>0);
 
update facturacion set monto_iva=(sub_total*alicuota_iva)/100
where (tipo_factura='Consumo') and (tipo_tarifa='Industrial B') and (alicuota_iva<>0);


Gracias por su atencion...

egostar 28-10-2008 21:03:09

Hola

A mi se me hace muy raro que hagas todo esto en un procedimiento, sobre todo estas dos instrucciones

Código SQL [-]
update facturacion set monto_iva=(sub_total*alicuota_iva)/100
where (tipo_factura='Consumo') and (tipo_tarifa='Industrial A') and (alicuota_iva<>0);
 
update facturacion set monto_iva=(sub_total*alicuota_iva)/100
where (tipo_factura='Consumo') and (tipo_tarifa='Industrial B') and (alicuota_iva<>0);

Para que lo diferencias si al final haces lo mismo.....

Código SQL [-]
update facturacion set monto_iva=(sub_total*alicuota_iva)/100
where (tipo_factura='Consumo') and (alicuota_iva<>0);

Por otro lado, esto lo haces en un proceso normal o estas haciendo una actualizacion de datos ya existentes?????

Salud OS

sierraja 28-10-2008 21:50:04

Correcto esto lo hago ejecutando un procedimiento normal desde la herramienta ibexpert con una base de datos existente, y cualquiera de esas instrucciones deberia ejecutarse de cualquier manera, ya que las condiciones en la tabla estan dadas, lo raro es que no actualiza ningun registro.

jhonny 28-10-2008 21:59:55

Cita:

Empezado por sierraja (Mensaje 322973)
Correcto esto lo hago ejecutando un procedimiento normal desde la herramienta ibexpert con una base de datos existente, y cualquiera de esas instrucciones deberia ejecutarse de cualquier manera, ya que las condiciones en la tabla estan dadas, lo raro es que no actualiza ningun registro.

Luego de ejecutar cada una de las instrucciones presiona las teclas CTRL+ALT+C y le dices que si quieres confirmar la transacción... o simplemente presiona el botón con un icono de "visto bueno" verde que esta en la parte superior para hacer el commit a tu consulta.

sierraja 28-10-2008 23:03:48

Perdon por olvidar mencionar ese detallazo. Claro, despues de cada ejecucion, persiono eje boton mencionado para hacer un commit pero aun asi no hacen la actualizacion, inclusive, cierro la bd y la vuelvo abrir y nada. No estoy seguro lo que pasa. Tambien he ejecutado cada instruccion con una ventana de SQL y realizo todos los pasos necesarios pero tampoco hace nada. Relmente me preocupa por no conseguir cual es el problema real. Gracias por el apoyo.

boreg 28-10-2008 23:10:53

Y los datos de los campos que comparas ¿están escritos como en tus instrucciones (mayusculas y minusculas)?, haz un

Código SQL [-]
select * 
from facturacion
where "TUSCONDICIONES"

para ver si te devuelve registros.

sierraja 28-10-2008 23:34:14

Correcto, ya hice un chequeo en la tabla y los registro en las columnas estan escritos identicamente a como se buscan. Algo que no he mencionado es que la table tiene 320.000 registros (y que no tiene nada que ver con el problema presentado) pienso yo. De todas maneras probaremos otra sugerenia. Gacias por su atencion....


La franja horaria es GMT +2. Ahora son las 17:42:44.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi