In versions less than 12 you need to set the increment property with the current value only negative and call nextval to reset the current and return the increment to the pattern you use, thus "zeroing" to Quence, example:
declare
ValorAtual integer;
begin
select Seq_teste.NEXTVAL * -1 into ValorAtual from dual;
execute immediate 'ALTER SEQUENCE Seq_teste INCREMENT BY '||to_Char(ValorAtual) || ' minvalue 0';
execute immediate 'SELECT Seq_teste.NEXTVAL FROM dual' into ValorAtual;
execute immediate 'ALTER SEQUENCE Seq_teste INCREMENT BY 1';
end;
In version 12 there is a command to reset sequences:
alter sequence Seq_teste restart start with 1;
To automate this process, you can create a procedure with the necessary script and create a scheduled job to run every turn of the year.
Without you showing a snippet of code or anything like that it gets very complicated to help you.
– Sorack
But I have no doubt in a code that I’m creating, I want to know if there’s any way I can reset a number from what it is for 1 every time I turn the year...
– Felipe Avelar
Have some ideas here. They are in English but it seems that there is no answer 100%
– Sorack
Be careful when using sequences as they ensure uniqueness but not integrity , if a numbering cannot fail they are not recommended.
– Motta
I don’t need integrity, just oneness anyway.
– Felipe Avelar