Create sequence with var as start number

Hi,
I would like to create a squence that starts with a number, which would be the
maximum number I got from DEPTNO column of TEST table +1, so I have the following
pl/sql stmts:
VARIABLE g_max_number NUMBER;
DECLARE
v_max_number NUMBER;
BEGIN
SELECT max(DEPTNO) INTO v_max_number FROM TEST;
v_max_number := v_max_number + 1;
:g_max_number := v_max_number ;
END;
create sequence test_s1 increment by 1 start with :g_max_number;
(or start with g_max_number)
however, I got error ORA-01722: invalid number. It looks like I can
not use a varible as start number for sequence.
How can I achieve what I want to do (create a sequence that starts with
a variable which I compute from a table) in Oracle?
Thank you very much for your help.
Irene
null

Hi
Use Dynamic SQL
The following Code should work in Oracle 8i.
HTH
Arvind Balaraman
DECLARE
v_max_number NUMBER;
stmt Varchar2(2000) := NULL;
begin
SELECT max(DEPTNO) INTO v_max_number FROM TEST;
v_max_number := v_max_number + 1;
stmt := 'create sequence test_s1 increment by 1 start with '| |to_char(v_max_number);
execute immediate stmt;
end;

Similar Messages

  • Cannot create sequence with nocache

    hi there,
    actual I try Raptor build 919 and I have a problem with creating sequences with NOCACHE using the wizzard.
    When I want to create a sequence with NOCACHE, the DDL shown in the wizzard is: CREATE SEQUENCE SEQUENCE1 INCREMENT BY 1 START WITH 1 MAXVALUE 10 MINVALUE 1 ;
    So the sequence is created with CACHE and cache size 20. After creating it is possible to switch the sequence to NOCACHE.

    I just checked in our bug database and this was fixed in our development version 1060 so it will be fixed in our next Early Adopter release (post v919).
    -- Sharon

  • JSR-75 PIM API creating Contact with more than one Number (Phone,Fax ...)

    Hi everybody
    I try to create a contact with more than one Phonenumber using the method contact.addString(...) .
    Contact with one single number is no Problem but contacts with more than one Number are ignored and are not stored to the phonebook. I try to add the Numbers using a for -loop. Is there an other way to solve this Problem?
    please Help.
    Thank You.

    Wonder if you have made any progress - if so,
    could you share ?

  • Create sequence help

    Hi all
    please
    How to create sequence with alpha
    like example
    aaa
    aab
    aac
    aad
    aaz
    aba
    abb
    abc
    abd
    abz
    aca
    acb
    acc
    acd
    acz
    ada
    adb
    adc
    add
    adz
    xyz
    xza
    ...

    DROP SEQUENCE S
    CREATE SEQUENCE S START WITH 0 MINVALUE 0
    DECLARE
        v_decimal NUMBER;
        v_base26  VARCHAR2(10);
    BEGIN
        FOR rec in (select s.nextval v_i from dual connect by level <= 52) LOOP
          v_decimal := rec.v_i;
          v_base26  := NULL;
          LOOP
            v_base26 := CHR(ASCII('A') + MOD(v_decimal,26)) || v_base26;
            EXIT WHEN v_decimal < 26;
            v_decimal := TRUNC(v_decimal / 26) - 1;
          END LOOP;
          DBMS_OUTPUT.PUT_LINE(TO_CHAR(rec.v_i,'999.') || ' ' || v_base26);
        END LOOP;
    END;
    0. A
    1. B
    2. C
    3. D
    4. E
    5. F
    6. G
    7. H
    8. I
    9. J
    10. K
    11. L
    12. M
    13. N
    14. O
    15. P
    16. Q
    17. R
    18. S
    19. T
    20. U
    21. V
    22. W
    23. X
    24. Y
    25. Z
    26. AA
    27. AB
    28. AC
    29. AD
    30. AE
    31. AF
    32. AG
    33. AH
    34. AI
    35. AJ
    36. AK
    37. AL
    38. AM
    39. AN
    40. AO
    41. AP
    42. AQ
    43. AR
    44. AS
    45. AT
    46. AU
    47. AV
    48. AW
    49. AX
    50. AY
    51. AZ
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Configured Item -  append sequence with item segment

    Hi,
    Is there any possible to have sequence number starting from 1,2,3... for each CTO BOM?
    Say for example, there is a CTO BOM and out of which 10 possible configurations can be done and each configured item shoud have itemsegment-1, itemsegment-2...etc.
    Thanks in Advance!
    Kaveri

    Hi Sabari,
    Configurable BOM - item segment is C0200D0000XX and the setup made in BOM Parameters is 'Append sequence with Item Segment'
    The number generated for one of configuration is C0200D0000XX-6202980.
    My question is can't the sequence be started with 1 for each configurable BOM? If so how to do it?
    Example:
    Configurable BOMS - C0300D0000XX which supports five possible valid configurations and the item numbers expected are C0300D0000XX-1, C0300D0000XX-2, C0300D0000XX-3, C0300D0000XX-4, C0300D0000XX-5
    Another CTO BOM C00600D0000XX which supports 3 valid configurations and numbers would be C00600D0000XX-1, C00600D0000XX-2,C00600D0000XX-3
    Thanks,
    Kaveri

  • Can't create events with times between 10:01 and 19:59

    I've recently updated to OSX 10.4.9, and now can't create events with times that start with a '1'. This only seems to be a problem on the day British Summer Time begins on 25 March.
    I usually create my events in the month view, and input the start and end times by clicking in the time boxes and typing in the hours and minutes. However when I try to put in a start time of, say, 11:00, it puts in 21:00 instead. The only way around this seems to be to put in a time it will accept, like 09:00, and using the arrow keys to move it to the time I want. Or creating the events in the day view and clicking on the start time there.
    Any ideas?

    Looks like you have found a wee bug. I can replicate it. You could report it though OS X Feedback or better though ADC, but for the latter you have to register first.
    I usually create events by double-clicking in week view; often this gets the start time right, but if not then edit the start time in the info pane. Your bug is there with events created in day and week views too.
    AK

  • Create Sequence Number with Select Query

    Hi All,
    I would like to create a sequence number in oracle but instead of hard coding the "start with" I want to select the max value of the primary key of a table and add 1 and use this instead:
    So what I want is:
    CREATE SEQUENCE crg_mrec_seq
    MINVALUE 1
    MAXVALUE 999999999999999999999999999
    START WITH select max(primarykey)+1 from table1
    INCREMENT BY 1
    CACHE 20;I'm guessing I need to pass this max value as a variable into the create sequence number but I'm not sure what syntax to use.
    Thanks,
    Ed

    spalato76 wrote:
    Hi All,
    I would like to create a sequence number in oracle but instead of hard coding the "start with" I want to select the max value of the primary key of a table and add 1 and use this instead:
    So what I want is:
    CREATE SEQUENCE crg_mrec_seq
    MINVALUE 1
    MAXVALUE 999999999999999999999999999
    START WITH select max(primarykey)+1 from table1
    INCREMENT BY 1
    CACHE 20;I'm guessing I need to pass this max value as a variable into the create sequence number but I'm not sure what syntax to use.
    Thanks,
    Edconstruct SQL statement & then EXECUTE IMMEDIATE

  • For what are "CREATE  SEQUENCE ... INCREMENT BY 1 START WITH 1" ?

    I have seen SQL statements for Oracle Databases in the form like
    CREATE SEQUENCE sq_ordernum INCREMENT BY 1 START WITH 1
    For what are these kind of statements and how can I access/use them?
    Peter

    sequence is used to increment a number when ever you use seq.next val;
    SQL> CREATE SEQUENCE sq_ordernum INCREMENT BY 1 START WITH 1
      2  /
    Sequence created.
    SQL> select sq_ordernum.nextval from dual;
       NEXTVAL
             1
    SQL> select sq_ordernum.nextval from dual;
       NEXTVAL
             2
    SQL> select sq_ordernum.nextval from dual;
       NEXTVAL
             3
    SQL> select sq_ordernum.nextval from dual;
       NEXTVAL
             4
    SQL> select sq_ordernum.nextval from dual;
       NEXTVAL
             5
    SQL> select sq_ordernum.currval from dual;
       CURRVAL
             5
    SQL>

  • Create sequence start with variable

    Trying to create a sequence within plsql passing a variable into the start with clause. I am getting the 'ora-01722: invalid number' error. Thoughts?
    -- Created on 06-Jun-07 by CARSONBC
    declare
    -- Local variables here
    v_staff_proxy_user_seq_num number;
    begin
    -- find max value
    select max(staff_proxy_user_id)+1
    into v_staff_proxy_user_seq_num
    from icmr32dv.staff_proxy_user;
    -- create sequence
    execute immediate 'create sequence icmr32dv.staff_proxy_user_seq2 minvalue 1 maxvalue 999999999999999999999999999 start with v_staff_proxy_user_seq_num increment by 1 nocache';
    end;

    What is the requirement of creating sequnce dynamically.?
    may be you can try this?
    execute immediate 'create sequence icmr32dv.staff_proxy_user_seq2 minvalue 1 maxvalue 999999999999999999 start With  '|| v_staff_proxy_user_seq_num || '  increment by 1 nocache';

  • Operation Start failed on step Allocate elastic IPs with message: Error creating static IPs; AMAZON: The maximum number of addresses has been reached.

    Hi All,
    I was trying to create Instance for SAP Application Server ABAP 7.4 SP5 incl. Business Warehouse on SAP HANA 1.0 SP7 [Developer Edition] in SAP HANA Enterprise Cloud / Cloud Appliance Library when I got this message 'Operation Start failed on step Allocate elastic IPs with message: Error creating static IPs; AMASON: The maximum number of addresses has been reached'.
    I tried looking for an answer or solution for this issue but no success.
    Can anyone please help me with this?
    Regards,
    Deep Tanwar

    Hi Deep,
    you need to check your Elastic IP limits within the AWS console and how to release them if they are used:
    Elastic IP Addresses (EIP) - Amazon Elastic Compute Cloud
    AWS Service Limits - Amazon Web Services
    Regards,
      Hannes

  • How to create a sequence with followoing specs....

    Hello all,
    I have to create a sequence with following specs:
    data type: number
    no. of digits: 6
    classification:
    1st digit starts from 5
    next 2 digits represent current year e.g. 06
    and next 3 digits = running serial (001 to 999)
    increament: 1
    example: 506001
    please help me
    regards/gulzar

    it is pre assumption that the running serial will not go beyond 999 in a year
    the ceiling is 500 per year
    yes its a y2.1k issue but we are not supposed to store a uniqe identifier for more than 100 years in the database.
    i m a novice, can you please suggest a code template for such a seq.?

  • How to create a a labview sequence with teststand

    hi  everybody,
    it might be this question but i haven't found any. I am using TestStand 2.0 and LabVIEW 7.0 and i wanna use labView Sequence adapter to create sequences by using labView step.
    So that's how i do.
    1) After choosing the labveiw standard prototype adapter, i select a step in the sequence let's say the numeric limit step
    2) then I specify the module and choose the option create VI...
    3) Then I have a labview front panel window that appears with test data and error out
    4) I just add a sequence context in the front panel, take a set property value module, link that module to  the sequence context and in the test data as show as in different examples i found
    5) but after all when i run the step that is error message i have:
         LabVIEW : parameter Sequence Context not found in the VI's connector pane.
         -18002; LabVIEW reported an error. See 'LabVIEW : ' message for more details.
    it's seems that i don't connect my sequence context to the VI's connector pane but i don't know how to do it. i tried to figure that out by reading some previous post but i still can't.
    First what's is a VI's connector pane and do you have access to that? Can you explain me that step by step
    Thanks in advance for your help.
    Christelle

    Hi,
    In the Specify LabVIEW Module is a checkbox if you need the Sequence Context in your VI.
    You should enbale this before creating the VI. If this is done, then you will not have to add the sequence context control to your VI, because it will already be there.
    But from your notes, you dont appear to be adding the Sequence Context control to your VI connector pane.
    If you do this, then it should all start to work.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Is there a way to start a Sequence with Task Manager (Windows)

    Hi
    Is there a way to start a Sequence with Task Manager (Windows)?

    Hi,
    That is too bad I can not schedule my action Wizard to run via Windows scheduler... The funney things about is that on the same machine that I have created the Action Wizard and saved to to my desktop via export, when I click on it to run it asks me you want to Import that action to your Acrobat Pro X? Okay or Cancel... That Action is already there in my action Wizard List and I have exported from this same machine and I was trying to see if I can schedule it via this command:
    C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat <C:\Users\Bahram\Desktop\OCRFaxedPDFs.sequ
    Regards,
    Jeff P.

  • How to export image sequence with a specific number

    Hello
    I'm looking how, like in after, I can export an image sequence with a starting specific number. I spend hours to rename images with Renamer, boring, stupid!
    Thank you for helping
    Alex

    Use Bridge.  You can do them all at once with Batch Rename.

  • Script to drop/re-create sequences is generated with errors

    Hello,
    I'm migrating an Oracle 10g instance running on Solaris 10 to an Oracle 11g instance running on RedHat Linux. I'm following the "Platform Migration" White Paper ( URLhttp://www.oracle.com/technology/deploy/availability/pdf/maa_wp_11g_platformmigrationtts.pdf ).
    In the appendix, there's the code for a script that's supposed to generate an SQL script that drops and re-creates the sequences on the target machine:
    set heading off feedback off trimspool on escape off
    set long 1000 linesize 1000 pagesize 0
    col SEQDDL format A300
    spool tts_create_seq.sql
    prompt /* ========================= */
    prompt /* Drop and create sequences */
    prompt /* ========================= */
    select regexp_replace(
    dbms_metadata.get_ddl('SEQUENCE',sequence_name,sequence_owner),
    '^.*(CREATE SEQUENCE.*CYCLE).*$',
    'DROP SEQUENCE "'||sequence_owner||'"."'||sequence_name
    ||'";'||chr(10)||'\1;') SEQDDL
    from dba_sequences
    where sequence_owner not in
    (select name
    from system.logstdby$skip_support
    where action=0)
    spool off
    I have run it on my Solaris machine, and it generates a file that looks like this:
    /* ========================= */
    /* Drop and create sequences */
    /* ========================= */
    CREATE SEQUENCE "MDSYS"."TMP_COORD_OPS" MINVALUE 1000000 MAXVALUE 2000000 INCREMENT BY 1 START WITH 1000000 NOCACHE NOORDER CYCLE
    CREATE SEQUENCE "MDSYS"."SDO_TOPO_TRANSACT_SUBSEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE ORDER NOCYCLE
    I don't have any "drop sequence" commands, and there is no semicolon (;) at the end of the "create sequence" lines, so those are not executed.
    I'm not at all familiar with PL/SQL, could somebody point me to the error?
    Thank you,
    Adrian

    Why do you need the "REGEXP_REPLACE ()" function?
    This would be simpler:
    SET long 32000 longc 80 pages 0 lin 80 trims on
    COL ddl wor
    SELECT    'DROP SEQUENCE "'
           || sequence_owner
           || '"."'
           || sequence_name
           || '";'
           || CHR (10)
           || DBMS_METADATA.get_ddl ('SEQUENCE', sequence_name, sequence_owner)
           || ';'
           || CHR (10) DDL
      FROM dba_sequences
    WHERE sequence_owner NOT IN (SELECT NAME
                                    FROM SYSTEM.logstdby$skip_support
                                   WHERE action = 0);
    /:p

Maybe you are looking for

  • Problem with underlining text in CS3

    I'm trying to underline a few bits of text, but I'm having trouble, as there doesn't seem to be an underline tool in Flash. The file I'm trying to do this in is here: http://alpan.secure-mall.com/test.html The glow effect on the text is triggered by

  • Is there a way to hide gridlines in Numbers?

    This is not the same as custom borders on cells -- I'm referring to the soft gray cell grid on the screen. I'm doing some work requiring screen shots, and they would look better without the lines.

  • Moving XI scenario's

    Hi, My client wants to test inetgration scenario's between newly installed ECC server and old XI server. Please know that both the systems are on different servers and the SLD entries in XI correspond to the old ECC server. Is it possible that we can

  • Exchange 2007 inaccessible

    I've spent an hour and a half with a helpful Apple Techsupport guy, but nonetheless to no avail. Mail.app, iCal.app, and AddressBook.app just won't cough up any details that can help me: Exchange 2007 remains inaccessible to me from the outside (I on

  • Updated to iTunes 11.0.4 - now where's my stuff!?

    After updating to 11.0.4 my library appears to be empty.  I have all my music and movies on a ReadyNAS, nothing locally on my harddisk, but as of today when I open iTunes and point to where my iTunes Media folder is, it appears to be empty.  All the