Home » Developer & Programmer » Forms » set the increment no
set the increment no [message #134222] Tue, 23 August 2005 23:10 Go to next message
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 #134266 is a reply to message #134222] Wed, 24 August 2005 02:27 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Is there a JX000001, JL000001, and JA000001? Or are the numbers independant of the prefix?

David
Re: set the increment no [message #134270 is a reply to message #134266] Wed, 24 August 2005 02:41 Go to previous messageGo to next message
swchen
Messages: 15
Registered: July 2005
Location: malaysia
Junior Member
is prefix like

JA00001 JX00001
JA00002 JX00002
Re: set the increment no [message #134272 is a reply to message #134222] Wed, 24 August 2005 02:47 Go to previous messageGo to next message
weekend79
Messages: 198
Registered: April 2005
Location: Islamabad
Senior Member

swchen

Why not let the user to enter the same manually. It is faxable for users & easy for you.
But if still want to do it I have long way solution for you as under:-

1st create a sequence “SeqJournal”
2ndly on item “journal_type”
Set a post_text_item trigger as follows:
-------------------------------------
Declare
Temp1 varchar2(20);
Begin
Select SeqJournal.nextval into Temp1 from dual;
:YourBlock.JNL_NO := ( YourBlock.journal_type ||’’|| Temp1);
End;
----------------------------------------------------------------

In case of problem ask again.

Wishes
Jawad
Re: set the increment no [message #134422 is a reply to message #134272] Wed, 24 August 2005 18:40 Go to previous message
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
Previous Topic: Trigger for update of non-db items???
Next Topic: Silent database disconnection
Goto Forum:
  


Current Time: Thu Sep 19 22:47:26 CDT 2024