|
|
Re: sequence nos [message #172691 is a reply to message #172437] |
Wed, 17 May 2006 12:01 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
vijaykkiran
Messages: 5 Registered: April 2006
|
Junior Member |
|
|
hi
in your code there is a little bit error in using the substr function, the function will accept 3 parameters.
1st is the column name,
2nd is the starting position,
3rd is the lenght to read..
invoice_no
-----------
s00001
s00002
s00003
so, 's' is truncated then length is 5 so from position 2 to length of 4 should be use.. i.e. substr(invoice_no,2,4) as for your column values
so, make change this.
if the invoice_no column is varchar2 format then its is very happy,
just add a number to the existing values by this
declare
num number;
begin
select max(to_number(substr(invoice_no,2,4)))+1 into num from Inv_table;
:inv_no := 'S'||lpad(num,3,0);
end;
|
|
|