Cursor with PostgreSQL

0

I have here a process table that activates a trigger when a new process is written. In my case, when someone generates a process for a request that was returned the system must "return" the quantity of items that were requested in that request to the item table.

I made a trigger here for this and I'm using cursor. The part of trigger that was to return the items is not working. How can I 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;
    
asked by anonymous 02.04.2018 / 22:55

0 answers