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)
-   -   como actulizar un tabla desde un store procedure como un ciclo.. (https://www.clubdelphi.com/foros/showthread.php?t=28184)

uper 12-12-2005 19:34:28

como actulizar un tabla desde un store procedure como un ciclo..
 
hola club

debo realizar una actualizacion entre tablas y he elegido usar store procedure con interbase6, la cuestion es que ya tengo el script pero no me hace lo que le digo:

Código PHP:

tengo una tabla fact_detalle con estos campos
FDET_ID
FDET_ELEMENTOFDET_CANTIDADFDET_PRECIOFDET_PEDIDO
y una tabla de Pedidos
DET_IND
DET_ORDENDET_CANTIDADDET_RESTANTE 

el Sp lo q- hace es lo siguiente, hace un select de Fact_detalle, guarda los campos fdet_pedido, fdet, cantidad, fdet_elemento, luego busca en el pedido DET_ORDEN, y el detalle det_id, y hace una resta para saber si es >0 sobra unidades y si es <0 falta unidades o bien si esta igual esta completo las unidades. (DET_CANTIDAD).

Código:

este es el store procedure
select count(*) from Fact_detalle where fdet_tipo='PED' and fdet_Id=: FDETALLE INTO :Contar;
if (:Contar>0) then
  FOR select fdet_pedido, fdet_elemento, fdet_cantidad from Fact_detalle
  where fdet_tipo='PED' and fdet_Id=:FDETALLE INTO :F_PEDIDO, :F_ELEM, :F_CANTIDAD do

  select DET_CANTIDAD from pedidos_detalle where DET_STATUS='E' and DET_IND=:F_PEDIDO AND DET_ORDEN=:F_ELEM
  into :deta_cantidad;
    R=F_CANTIDAD-deta_cantidad;

    if (R=0) then                /* completo */
      Update pedidos_detalle set DET_RESTANTE=0 where DET_IND=:F_PEDIDO AND DET_ORDEN=:F_ELEM;
    else
    if (R>0) then  /*  hay demas uniddes
      Update pedidos_detalle set DET_RESTANTE=0 where DET_IND=:F_PEDIDO AND DET_ORDEN=:F_ELEM;
    else
      if (R<0) then /*faltan unidades
        Total=R*(-R);  /* para que no sea un valor negativo
       
      Update pedidos_detalle set DET_RESTANTE=:Total where DET_IND=:F_PEDIDO AND DET_ORDEN=:F_ELEM;

de lo que se trata es de que en la tabla de pedidos me actulize el campo restante con este dato se conoce si aun faltan unidades para hacer mas partidas
me hace falta algo.
gracias.

StartKill 14-12-2005 14:43:03

Holas,

Al simple vista no veo el begin y el end.

Se supone que el for es un bucle de un conjunto de registros,
pero el begin y el end que contiene ese bloque???

Your friend

StartKill
Lima-Perú


La franja horaria es GMT +2. Ahora son las 15:46:56.

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