create or replace trigger TRG_TABELA_TRANSACAO
before insert on TABELA_TRANSACAO
for each row
declare
-- local variables here
begin
SELECT transacao_seq.nextval
INTO :new.ID
FROM dual;
end TRG_TABELA_TRANSACAO;
Do you have a multi-record block? You can make a get in the blocks and pick up the current_record,
that is the segerial of registration,
or if it is not a multi record, and is commanded registration, you can make a query that Return a Segendancy by CD_Transacao,
sure, to make a "max + 1" is not a good practice, but everything depends on the situation,
in this case for what I understood it will have a number of items for each transaction,
would have to have a number of items representative so that the slowness is noticed,
being that he would have to seek the sequential transaction and not from the table,
but everything depends on the case,
DECLARE
CURSOR CUR_INCREMENTO IS
SELECT MAX(NVL(:TB_ITEMTRANSACAO.NR_SEQ,0)) + 1
FROM TB_ITEMTRANSACAO WHERE CD_PRODUTO = :BLK_LANCAMENTO.CD_LANCAMENTO;
BEGIN
OPEN CUR_INCREMENTO;
FETCH CUR_INCREMENTO INTO :TB_ITEMTRANSACAO.NR_SEQ;
CLOSE CUR_INCREMENTO;
END;
But whenever I do the process he plays 1 for cadas record in the nr_seq field
To work out the sequence you would have to start registration registration, as it seeks the Max of the bank, which, if you did not commit the previous record it will always be the same,
How to upgrade the sequence of a multi block record if for example, delete a registry of the middle of the sequence, how to reorder sequencing?
I tried some alternatives to cross the block with loop to redo the sequence, but I do not know which trigger to use, some are restricted and do not allow
Hello, good morning ... I need to do the same, insert a sequence to the next registration, in my case this sequential would be nr of concierge, so I wanted to open the form already opened with this nr filled ... but as I have only 1 month In Apex5, I do not know where I put the code to work, could you help me ??