How to use new sequence when one is reached its maxvalue in PL SQL code

Hi,
Currently, I am populating a unique product serial number in a table column using a sequence call to generate new number. For different products, I have different sequences and in my PL SQL code usiing IF..Else block I populate serial number for different products. For one most selling product sequence, we are reaching a Max value in production in a month and to make sure that application will continue to work fine for various end users without getting any error on their screens, I want my code to switch to new sequence automatically. I just need to add another if condition but my problem is how to find accurately when max value is reached for old sequence.
As call to old sequence can happen in different sessions there could be inconsistency and can end up at error. My new sequence value has to start with AV1000. Please suggest.
My old sequence look like this :
SEQUENCE Prd
INCREMENT BY 1
START WITH AS1000
MAXVALUE AS9999
MINVALUE AS1000
CYCLE NOCYCLE
CACHE 2
Order Yes;
Edited by: user11695088 on Jul 15, 2009 12:14 AM

Catch the exception and use your new sequence. But somehow, I'm not liking your alternative approach.
SQL> set line 300
SQL> set pages 50000
SQL> set serveroutput on
SQL> create sequence testing_seq increment by 1 start with 1 maxvalue 3
  2  /
Sequence created.
SQL>
SQL> create or replace procedure test_seq_proc(p_seq out number)
  2  is
  3  begin
  4     select testing_seq.nextval
  5     into p_seq
  6     from dual;
  7  --
  8     dbms_output.put_line(p_seq);
  9  --
10  end;
11  /
Procedure created.
SQL> declare v_out number;
  2  begin
  3     test_seq_proc(v_out);
  4  end;
  5  /
1
PL/SQL procedure successfully completed.
SQL> /
2
PL/SQL procedure successfully completed.
SQL> /
3
PL/SQL procedure successfully completed.
SQL> /
declare v_out number;
ERROR at line 1:
ORA-08004: sequence TESTING_SEQ.NEXTVAL exceeds MAXVALUE and cannot be instantiated
ORA-06512: at "ETL_ADMIN.TEST_SEQ_PROC", line 4
ORA-06512: at line 3
SQL>Cheers
Sarma.

Similar Messages

  • How dose family sharing work when one person wants to use a gift card?

    How dose family sharing work when one person wants to use a gift card?

    kokogo,
    Purchases made in the iTunes and App Stores will first attempt to use any store credit that exists on the purchaser's account. Barring sufficient credit, the family organizer's card will be used for the purchase.
    First, their store credit will be used to pay the partial or total bill. The remainder will bill to the family organizer's card. As the family organizer, any receipts generated by the transaction will be sent to you. Learn more about how iTunes Store purchases are billed.
    Family purchases and payments
    https://support.apple.com/en-us/HT201079
    Sincerely,
    Allen

  • How to use multiple ipods on one account

    I have an Ipod classic and just bought my sons two nano's how do I use these on the same account without changing my account info?

    Take a look here:
    How to use multiple iPods with one computer
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Discussions page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums, in the User Tips Library and in the Apple Knowledge Base before you post a question.
    Regards.

  • Can someone tell me how to use 2 ipods on one computer

    well when anyone can ill be waiting for the answer i want to know cuz since im buying the ipod video i want to see if i can use the same computer that im uploading stuff to my ipod mini

    There is no limit to how many iPods can run on a single PC. Or how many PCs a single iPod can connect to. Either by Apple design or by any legal issues.
    These links should help:
    Natalie Beresford: Multiple iPods/iTunes Installations
    How to use multiple iPods with one computer
    How to share music between different accounts on a single computer

  • Help wanted - step by step process on how to use two ipods on one computer

    I'm just in the process of getting an ipod (waiting on delivery!) and want to know how it is possible to have two ipods using the same computer but synchronizing differently. I don't want to risk losing my partners music (he'll be very upset!) and I don't want to end up with his music on my ipod. I'd appreciate it if someone could give me a step by step guide or tell me where the best place to look for the answer is. Is it possible somehow to have two different libraries on one computer? Is that how it works?

    There are a couple of methods for using more than one iPod on a single computer. Have a look at the article linked below. Method one is to have two Mac or Windows user accounts which by definition would give you two completely separate libraries. Method two as Chris has already described above is to set your preferences so each iPod is updated with only certain playlists within one library. Have a look anyway and see what you think and go for whichever you feel suits your needs best: How To Use Multiple iPods with One Computer

  • HELLP!! NEED TO KNOW HOW TO USE TWO IPODS ON ONE COMP!ASAP

    i have an ipod nano and an itunes account. Now my mom has a nano and we need to know if you can register them on the same account and how or any other tips for using two ipods on one comp!
    PLEASE HELP ASAP!
    ZACH

    Hello Zach,
    There are a couple of methods for using more than one iPod on a single computer. Have a look at the article linked below. Method one is to have two Mac or Windows user accounts which by definition would give you two completely separate libraries. Method two is to set your preferences so each iPod is updated with only certain playlists within one library. Have a look anyway and see what you think and go for whichever you feel suits your needs best: How To Use Multiple iPods with One Computer

  • Is there a way to differentiate from two iPod touches that are on the same iTunes acct when using iMessage? When one child sends a message the other gets it and it says it's from our email address.

    Both of my sons have iPod touches. I set them both up on my iTunes account. The problem we are having is when they are using iMessage. When one sends a message the other also receives it. The message is labeled as from my email address. Is there a way to differentiate the 2 iPods?

    See:
    MacMost Now 653: Setting Up Multiple iOS Devices For Messages and FaceTime

  • How to use java script when popups are blocked in browser

    How to use java script when popups are blocked in browser

    Not. When people install a popup blocker they don't WANT popups, so stop trying to force them down their throats.

  • I am using iphone 5 when my picture reach 1000 automatic it deleted the old pictures any advice please

    I am using iphone 5 when my picture reach 1000 automatic it deleted the old pictures any advice please

    Rayooma wrote:
    A very thanx to reply to me how can i solve it do i have to format my i phone or whats your advice thank you
    Did you delete these photos from your iPhone?
    Look in the Camera Roll, not the Photo Stream.

  • How can i identify the environment name or database name in the PL/SQL code

    Hi,
    I am using UTL_FILE to genearate the files.,
    My problem is, I have to design the common sql file , which can be executed in 2 diffrent environments ( Say QA & DEV ) , with no parameters. It has to identify the environment and based on the environment , it has to generate the concern files.,
    The only change needs to be incorporated is , file names , which will change based on the environment.,
    can nay one tell me , how can i identify the environment name or database name in the PL/SQL code ??
    Raja

    In this case, USEC_GI_DEV.NA.XXXNET.NET is a TNS alias. That alias exists only on the client machine. There is no way to access that information on the database server.
    You would have to find something in the v$database or v$instance table that uniquely identifies the database (and you may need some help from the DBAs to do this because you need to ensure that the data element you choose is compatible with whatever refresh process(es) are used in your environment).
    Now, if you are writing a stand-alone SQL*Plus script, SQL*Plus, as a client tool, does have access to the TNS alias in later versions. But that is a client-side determination, not a server-side determination.
    Justin

  • How to use ODI sequences ??

    I have an interface which need an ODI sequence.
    When I execute it the value of the sequence is always the same.
    I have seen on another thread that it may pass by an agent but...
    I have 2 tables (source and target) from the same connexion which don't and won't have agent.
    How can I do ??
    My connexion is on an Oracle 10g RDBMS and I'm using an IKM SQL Control Append.
    This is not the first time I have problem with the ODI Sequence but this time I can't create an RDBMS one ...
    Thanks in advance,
    BM

    Hi guys,
    I have some questions, I am trying to create a dimension and it should use a sequence, but I am getting the same issue as you guys. I can't not generate a unique key because my sequence is the same value for all rows.
    So if I really understood there are two ways to use a sequence in ODI. One is using ODI sequence (creating it inside ODI) and other is using a RDBMS sequence.
    First: What I have to do to use a RDBMS sequence? (Step by step please)
    Second: I can't use an IKM SQL to SQL append in my interface. This interface is pretty simple - source is a flat file target is an Oracle table, I just need to move all flat files columns to Oracle table adding a sequence. I understood that my Staging area should be different than my Target area based on posts above. I already created a new datastore to be my new staging area, but I don't know how to make an association between interface and new stage area.
    Can you please provide me the easiest solution?
    Thanks
    Leo

  • How to use proxy settings for one website

    Hello,
    I have to access the only one website using Proxy settings and for others I don't need proxy to access. Is there a way to configure the internet settings to allow one website using Proxy... Please advise. Thanks!
    Regards,
    Aravin S

    I am also getting this "error".  The printer (8500 A910) connected to the web well enough that it went out and supposedly downloaded a new update, but then it was supposed to print a page showing the email address, but did not.
    So I go in and try to set up the eprint, and it tells me it cannot connect to the sever and I'll need to enter a proxy address and port number.  But my ISP's cable modems do NOT have any static IP address nor do they provide any sort of proxy service.  Everything works just fine with "automatic discovery" (DHCP) for every computer in the house.  No problems there.
    So, since  that's the case, of course I cannot look up some proxy address and port number in my web browser because they're all set up for "automatically detect settings".
    What's baffling is that the printer connected to something at HP to download the "update", and it went through a process that appeared to be what I'd expect it to do if it was updating its firmware.  But it won't connect to whatever it's supposed to connect to to have an email address assigned.
    Does HP supply a proxy server?  If so, what's its IP address or URL, and what port should a person set the printer to try to use?
    UPDATE:
    It appears that the HP site must have just been "down" for about six or seven hours while I was trying to get the printer to connect because it now connected and I got an email address asigned without needing to have any "proxy" stuff set up at all.  It's a shame that the printer does not simply report "HP Site down - try again later" instead of reporting that you need to use a proxy when that's impossible.
    "Now, on to the next problem which is that my emails to the assigned address are all bouncing with a "550 5.7.1 Command rejected" error!

  • How to use parallel sequence for split the operation qty. urgent or other o

    PP guru
    My scenario is as follows.
    I ve one material suppose…xyz.
    For that material I' ve created bom, routing.
    In routing I' ve mention only one operation. 0010.
    Now I' ve the production order of 1000 kg.
    I want to use two work centers to run this production order. ( e.g.work center a and b)
    In routing I used work center a.
    In short I want split that operation.
    So what I ve to do or use parallel sequence and how???
    or else is there any other option to split the order to two or more machines/work center?
    Pls explain me in brief.
    Regards,
    Ram

    Hi,
      If you want to carry the production with two different work centers , first you need to split the operation qty.
    For this in the order type dependent parameters OPL8
    in the controlling tab page enable the indicator Cost collector
    and set the default rule as PP2.
      Create a Product cost collector with KKF6N.
       Now in the production order , select the operation and choose functions--->>> split.
       Now enter the operation split quantity and execute.
       Now in MD04 you can see two production order.
       In the second production order change the work center in the operation overview as desired and save.
      Regards,
    nandha

  • How to use new patch updates in track

    Hi All,
    I am a developer working in NWDI. We have everything in place and working fine upto now.
    SAP has release a patch for the software component i am using in a track. Basis guys have updated the track and they confirmed the patch is updated successfully.
    Now when ever i rebuild my DC, the changes are not effected as per the new patch. Please let me how I will be able to use new patch updates in my DC(In NWDS I can see the old source code only, I did all SYNC's and refresh but didnt worked, even NWDI is restarted)
    How I can confirm that the patch is updated to track successfully, from a developer point of view.
    I have access to CMS and CBS.
    Regards,
    Sateesh Chandra

    Did you update your configuration in the studio?
    --MLS

  • How to use dynamic parameter when a report is created using Stored Procedures

    Hi all,
    any one have the idea of how to use dynamic parameter in crystal report XI R2
    when report is created using Stored Procedure.
    Regards
    shashi kant chauhan

    Hi
    You can create an SQL command in Database Expert > Expand your datasource > Add command
    Then enter the SQL query that will create the list of values to supply to the user
    eg select field1,field2 from table
    Then edit the parameter of the report.  These will be the SP parameters adn can be seen in field explorer.
    Change the parameter type to Dynamic
    Under the word Value click on Click here to add item
    Scroll down to your Command and select one of the values that you want to appear in the list
    e.g field1
    Then click on the Parameters field - this is essential to create the param
    You can edit other options as required
    That should do it for you.
    I must say that i use CR 2008 connected to Oracle 10g SP, but i reckon this will work for SQL DB and CR XI as well
    Best of luck

Maybe you are looking for

  • Error while unloading data from teradata to a flatfile

    while executing the interface that writes data into a flat file from a table, the interface fails with the error message "Bytes are too big for array" any idea ?

  • Microphone issues

    I am hooking up just a basic computer microphone to my G5 and I can't get it to work at all. Do I need a special mic?

  • Photo Gallery - Load Detail Image

    How can I load a different image other than the first one listed in the XML file? Example, let's say I have 20 photos in my XML file. The first detail image (large) to load is the first one in the list, how can I show the 15th one in the list when th

  • How to compile the DB lookup code for XI:

    Dear All, i am very new to java and XI. Please let me know how to compile a Java Code for DB lookup and put in the imported Archive in IR. is there a seperate way to do it? Please guide me step by step. for performing Communication channel DB lookup.

  • What's been the wait for in store reserves

    In particular the Southlake one. Thanks