Cursor with Postgresql

Asked

Viewed 34 times

0

I have here a table of proceedings that activates a Trigger when a new procedure is recorded. In my case, when someone generates a process for a request that has been returned the system must "return" the amount of items that were requested in this request to the table of items.

I made a Trigger here for this and I am using cursor. The part of the Trigger that was to return the items is not working. Could anyone how I can fix this?

       --Devclaração do cursor
         c_contrato_item                compras.contrato_requisicao_item%ROWTYPE;     

       --Trecho que era pra funcionar
       FOR c_contrato_item IN 
            SELECT ano, contrato, item, quantidade FROM compras.contrato_requisicao_item
              WHERE ano_requisicao = NEW.ano_requisicao AND requisicao = NEW.requisicao
       LOOP 
           UPDATE compras.contrato_item SET (quantidade_saldo) = ((quantidade_saldo + c_contrato_item.quantidade))
               WHERE ano = c_contrato_item.ano
                 AND contrato = c_contrato_item.contrato
                 AND item = c_contrato_item.item;
       END LOOP;
  • this Trigger is fired in the shopping table.contrato_requisicao_item ?

  • No, in the table of procedure. When generates the request process returned to it triggers

  • can put the whole code of Trigger?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.