Home » Developer & Programmer » Forms » Auti increamnet using seq. in form level (form 10g)
Auti increamnet using seq. in form level [message #493016] Fri, 04 February 2011 05:25 Go to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

Hi friend i created a simple seq. for auto-increamenting empno.

Code for sequence :
--------------------------

create sequence seq_empno
start with 8000
MAXVALUE 9000
INCREMENT by 1
nocache
nocycle

==========================================================

I created a form (herewith attached form),
my problem will arise supposed i pressed add button every time my seq. generated....but still i didnt press save button

Now scenario like this
1) prees add button
2) empno now become 8001
3) i neither enter any thing nor press SAVE button.
4) i press exit button
5) when i next time press add button same no ( 8001) will be generated again.
6) if this time i preess save button then empno would become 8002 on next time

I hope all of us undesrstand my scenarion

please helpp me
Re: Auti increamnet using seq. in form level [message #493027 is a reply to message #493016] Fri, 04 February 2011 05:52 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Bad news is that sequences don't work that way. Once it is "fired", it increments. If you need those values to increment by 1, always, you might need to create a table of "available" EMPNOs. You'd then fetch and store them into the EMP table in PRE-INSERT trigger.
Re: Auti increamnet using seq. in form level [message #493034 is a reply to message #493027] Fri, 04 February 2011 06:08 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
And if you do use the LF's alternative only 1 user will be able to insert emp records at a time as you'll need to lock the table.
Re: Auti increamnet using seq. in form level [message #493038 is a reply to message #493034] Fri, 04 February 2011 06:20 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Which means that database BEFORE INSERT trigger might be a better choice?
Re: Auti increamnet using seq. in form level [message #493048 is a reply to message #493038] Fri, 04 February 2011 07:04 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Won't make much difference. You'd still need to lock the table before doing the insert.
Plus if you do something that causes the record to be posted and not committed you could be holding onto that lock for a long time.
If you want a detailed discussion on the cons search on asktom for gapfree sequence.
Previous Topic: APPLET Size
Next Topic: how to handle multi row select statement.
Goto Forum:
  


Current Time: Tue Sep 17 16:20:07 CDT 2024