set the increment no [message #134222] |
Tue, 23 August 2005 23:10 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
swchen
Messages: 15 Registered: July 2005 Location: malaysia
|
Junior Member |
|
|
hello, to all here. I have some problem with the oracle form builder. Below are regarding my program problem:
I need set the field JNL_NO to be auto increment field when the new record insert. The JNL_NO data type are varchar-size length =8, first 2 character are journal type(inside the form have 1 field called journal_type) and following are the number the record of journal.
e.g-JX000001, JL000005, JA000111
So,how can genetrated the nummber correct follow the journal type???
|
|
|
|
|
|
Re: set the increment no [message #134422 is a reply to message #134272] |
Wed, 24 August 2005 18:40 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/67467.jpg) |
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
'faxable' - did you mean 'flexible'?
How about using the good old max+1 solution?
I suggest you store the information in two fields and then combine then on display. That is JNL_NO is JNL_PRFX concatenated with lpad(to_char(JNL_SEQ),5,'0').
Whichever way you do it you need to separate the prefix from the number. If you use two fields it is easier to validate the prefix (as two digit character,, from the set 'JX', 'JL', 'JA', etc). Then don't let the user enter the number. You do a
select max(nvl(jnl_seq),0)+1
into :your_block.jnl_seq
from your_table
where jnl_prfx = :your_block.jnl_prfx;
David
|
|
|