|
|
|
|
|
|
| Author |
Message |
Krist *nix forums beginner
Joined: 15 Mar 2005
Posts: 7
|
Posted: Fri Jul 21, 2006 7:30 am Post subject:
Strange problem with Sequence.. please help..
|
|
|
HI Gurus,
I develop application on Oracle 10.1.0.2.0 n Win2003. I am creating
Sequence for auto generation of document number column and that column
is part of PK. I put the logic to access the sequence on a Trigger
(attached below).
I have strange problem, it already occur several times, my document
number "jump" not to next sequence number. .e.g: ..32,33,55 (???)
What can cause this problem ?
Can it be because Export / Import ?
Below is my Trigger :
CREATE OR REPLACE TRIGGER TBI_INVOICE BEFORE INSERT ON INVOICE
FOR EACH ROW
BEGIN
IF :NEW.NODOKUMEN IS NULL OR :NEW.NODOKUMEN < 0 THEN
IF (:NEW.COMPID = 'ASP01') THEN
SELECT INVOICE_ASP_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF (:NEW.COMPID = 'SIO01') THEN
SELECT INVOICE_SIO_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF (:NEW.COMPID = 'SIU01') THEN
IF :NEW.docid = 'IV' THEN
SELECT INVOICE_SIU_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF :NEW.docid = 'TA' THEN
SELECT INVOICE_SIU_TA_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF :NEW.docid = 'TR' THEN
SELECT INVOICE_SIU_TR_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
END IF;
END IF;
END IF;
END;
Thank you for your help,
xtanto |
|
| Back to top |
|
 |
Gints Plivna *nix forums beginner
Joined: 21 Jun 2006
Posts: 27
|
Posted: Fri Jul 21, 2006 9:56 am Post subject:
Re: Strange problem with Sequence.. please help..
|
|
|
xtanto@hotmail.com wrote:
| Quote: | HI Gurus,
I develop application on Oracle 10.1.0.2.0 n Win2003. I am creating
Sequence for auto generation of document number column and that column
is part of PK. I put the logic to access the sequence on a Trigger
(attached below).
I have strange problem, it already occur several times, my document
number "jump" not to next sequence number. .e.g: ..32,33,55 (???)
What can cause this problem ?
Can it be because Export / Import ?
Below is my Trigger :
CREATE OR REPLACE TRIGGER TBI_INVOICE BEFORE INSERT ON INVOICE
FOR EACH ROW
BEGIN
IF :NEW.NODOKUMEN IS NULL OR :NEW.NODOKUMEN < 0 THEN
IF (:NEW.COMPID = 'ASP01') THEN
SELECT INVOICE_ASP_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF (:NEW.COMPID = 'SIO01') THEN
SELECT INVOICE_SIO_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF (:NEW.COMPID = 'SIU01') THEN
IF :NEW.docid = 'IV' THEN
SELECT INVOICE_SIU_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF :NEW.docid = 'TA' THEN
SELECT INVOICE_SIU_TA_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF :NEW.docid = 'TR' THEN
SELECT INVOICE_SIU_TR_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
END IF;
END IF;
END IF;
END;
Thank you for your help,
xtanto
|
By default (i.e. if you don't say explicitly create sequnce bla cache
<some number>) 20 sequence numbers are cached. In case of DB restart
you'll lose them. Also in case of rollback you may have gaps. Sequences
cannot be used to get _continuous_ numbers, they can be used to get
_unique_ numbers.
Gints Plivna
http://www.gplivna.eu |
|
| Back to top |
|
 |
Micha³ Kuratczyk *nix forums beginner
Joined: 07 Apr 2006
Posts: 10
|
Posted: Fri Jul 21, 2006 10:00 am Post subject:
Re: Strange problem with Sequence.. please help..
|
|
|
xtanto@hotmail.com wrote:
| Quote: | I have strange problem, it already occur several times, my document
number "jump" not to next sequence number. .e.g: ..32,33,55 (???)
What gave you the idea that this is strange? Read about this "problem" on |
http://asktom.oracle.com - it was talked about many times.
--
Michal Kuratczyk |
|
| Back to top |
|
 |
Charles Hooper *nix forums addict
Joined: 09 Jul 2006
Posts: 51
|
Posted: Fri Jul 21, 2006 10:04 am Post subject:
Re: Strange problem with Sequence.. please help..
|
|
|
xtanto@hotmail.com wrote:
| Quote: | HI Gurus,
I develop application on Oracle 10.1.0.2.0 n Win2003. I am creating
Sequence for auto generation of document number column and that column
is part of PK. I put the logic to access the sequence on a Trigger
(attached below).
I have strange problem, it already occur several times, my document
number "jump" not to next sequence number. .e.g: ..32,33,55 (???)
What can cause this problem ?
Can it be because Export / Import ?
Below is my Trigger :
CREATE OR REPLACE TRIGGER TBI_INVOICE BEFORE INSERT ON INVOICE
FOR EACH ROW
BEGIN
IF :NEW.NODOKUMEN IS NULL OR :NEW.NODOKUMEN < 0 THEN
IF (:NEW.COMPID = 'ASP01') THEN
SELECT INVOICE_ASP_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF (:NEW.COMPID = 'SIO01') THEN
SELECT INVOICE_SIO_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF (:NEW.COMPID = 'SIU01') THEN
IF :NEW.docid = 'IV' THEN
SELECT INVOICE_SIU_IV_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF :NEW.docid = 'TA' THEN
SELECT INVOICE_SIU_TA_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
ELSIF :NEW.docid = 'TR' THEN
SELECT INVOICE_SIU_TR_SEQ.NEXTVAL INTO :NEW.NODOKUMEN FROM DUAL;
END IF;
END IF;
END IF;
END;
Thank you for your help,
xtanto
|
Typically, the sequence numbers are cached in groups of 20 when created
with the default options. If you restart the Oracle instance/database
the cached numbers will be lost. If the sequence .NEXTVAL would have
pulled a value of 6, after restarting the Oracle instance/database the
..NEXTVAL would pull 21. The number of sequence numbers cached can be
adjusted, but may impact performance if set too low. If your code
executes a .NEXTVAL and then performs a rollback, Oracle does not
rollback the sequence to the previous number, since another session may
have already executed a .NEXTVAL for the same sequence.
Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc. |
|
| Back to top |
|
 |
Brian Peasland *nix forums Guru
Joined: 04 Apr 2006
Posts: 301
|
Posted: Fri Jul 21, 2006 1:31 pm Post subject:
Re: Strange problem with Sequence.. please help..
|
|
|
| Quote: | If you restart the Oracle instance/database
the cached numbers will be lost.
|
Additionally, the sequence number are cached in the Dictionary Cache.
Depending on activity and the configuration of your server, it is
possible for the
sequence information to get aged out of the cache. So you can lose
sequence numbers without a restart of the instance.
HTH,
Brian
--
===================================================================
Brian Peasland
dba@nospam.peasland.net
http://www.peasland.net
Remove the "nospam." from the email address to email me.
"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sat Nov 22, 2008 9:31 pm | All times are GMT
|
|
Web Advertising | Loans | MPAA | Debt Consolidation | MPAA
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|