niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle » Server
Strange problem with Sequence.. please help..
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
Brian Peasland
*nix forums Guru


Joined: 04 Apr 2006
Posts: 301

PostPosted: Fri Jul 21, 2006 1:31 pm    Post subject: Re: Strange problem with Sequence.. please help.. Reply with quote

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
Charles Hooper
*nix forums addict


Joined: 09 Jul 2006
Posts: 51

PostPosted: Fri Jul 21, 2006 10:04 am    Post subject: Re: Strange problem with Sequence.. please help.. Reply with quote

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
Micha³ Kuratczyk
*nix forums beginner


Joined: 07 Apr 2006
Posts: 10

PostPosted: Fri Jul 21, 2006 10:00 am    Post subject: Re: Strange problem with Sequence.. please help.. Reply with quote

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
Gints Plivna
*nix forums beginner


Joined: 21 Jun 2006
Posts: 27

PostPosted: Fri Jul 21, 2006 9:56 am    Post subject: Re: Strange problem with Sequence.. please help.. Reply with quote

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
Krist
*nix forums beginner


Joined: 15 Mar 2005
Posts: 7

PostPosted: Fri Jul 21, 2006 7:30 am    Post subject: Strange problem with Sequence.. please help.. Reply with 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
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Thu Dec 04, 2008 7:26 am | All times are GMT
navigation Forum index » Databases » Oracle » Server
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Postfix + MySQL error: very strange variable %s iWarior Postfix 0 Mon Aug 25, 2008 2:01 pm
No new posts Unknown in header problem -SOLVED- Light Speed Postfix 0 Thu Jul 03, 2008 10:40 am
No new posts problem with sending mail nuxia Postfix 0 Mon Apr 21, 2008 3:58 am
No new posts Postfix 2.3.8 Virtual problem Blotto Postfix 0 Fri Apr 04, 2008 6:11 am
No new posts Postfix sending problem for local domain remote email monkey_magix Postfix 0 Mon Sep 10, 2007 10:17 am

Credit Check | Mortgage Calculator | Credit Cards | Debt Consolidation | Current Accounts
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
[ Time: 0.2083s ][ Queries: 20 (0.1209s) ][ GZIP on - Debug on ]