Sequences alter

hi experts,
i am very new to pl/sql procedures, we have requirement like to reset to sequence to starting value.
please share about how to alter a sequence using either function/procedure.
Thanks in advance.
Sh

Rooney's approach is the right one (though, as William suggests, it can be made more generic). I'd also point out that you'd have to be very certain that no other sessions are potentially accessing the sequence at the same time-- otherwise, you could end up with the NEXTVAL getting called multiple times between the two ALTER SEQUENCE calls that change the increment.
I would seriously question the requirement, however. The vast majority of time that people ask this, they are mis-using sequences because they're trying to do things like store that this is the Nth order placed so far this month. That's not what sequences are used for-- sequences are not gap-free so they won't tell you anything other than relative order (and possibly not even that in a RAC environment). Sequences are designed to efficiently produce distinct synthetic primary key values for multiple sessions. If you're using them that way, you shouldn't need to reset a sequence. If you're using them some other way, you're probably making a mistake.
Justin

Similar Messages

  • How can I use the "create book" feature without having my album photo sequence altered

    I have created an album with photos that are in a particular order for a reason.  I then process to create a book.  The template then rearranges all my photos.  Is there a way to keep them in the original order I set up? 

    All the 5000 photos that reappeared after repair today were from my canada mega event, but for some reason it did not do it for all the other mega events.  It is a start but not complete.
    Try the rebuild to recover more lost photos.
    If "rebuild" with iPhoto does not recover more lost photos, rebuild with iPhoto Library Manager as described by Old Toad in this thread, but rebuilding with iPhoto Library manager will not recover your projects like cards, bilks, slideshows.
    Re: iPhoto glitch with retained masters https://discussions.apple.com/message/26354337#26354337
    Mostly the way I organize all my photos is that I make a folder for each country I visit.  i.e. New Zealand Folder, Canada Folder, India Folder; and at the same time, any photos that I import I delete directly from new imports and just keep the ones i want and then i go up to events and move the latest imported event into a mega event for that country and so they all get joined in a sense.
    As a workaround, merge the events right after importing, before you start deleting photos.  And empty the trash always before merging projects.
    You might consider to use albums instead of events for your country lists.   I simply use the events as basic containers. One event for each day of shooting photos. I found, that smart albums and searches are quicker in iPhoto and Aperture, if the events are smaller, also browsing is easier, if the events are not so large.
    You can merge albums and remove photos from albums without the problems mentioned above.

  • Patch 3480000 install - Failed worker   ALTER SEQUENCE

    Dear All,
    I am in the process of installing Patch 3480000 (11.5.10.2) and during the running workers 1,3 fail and this the part of worker 1 log :
    The sequence IEM_ACCOUNT_TAG_KEYS_S1 in the database is defined as:
    MINVALUE = 1 MAXVALUE = 2000000000 INCREMENT BY = 1
    CYCLE = NO ORDER = NO CACHE = 20
    which should be defined as:
    MINVALUE = 10000 MAXVALUE = 2000000000 INCREMENT BY = 1
    CYCLE = NO ORDER = NO CACHE = 20
    Alter the sequence with :
    Start time for statement below is: Fri Apr 29 2011 14:51:14
    ALTER SEQUENCE IEM.IEM_ACCOUNT_TAG_KEYS_S1 MINVALUE 10000
    AD Worker error:
    The following ORACLE error:
    ORA-04007: MINVALUE cannot be made to exceed the current value
    occurred while executing the SQL statement:
    ALTER SEQUENCE IEM.IEM_ACCOUNT_TAG_KEYS_S1 MINVALUE 10000
    AD Worker error:
    Unable to compare or correct sequences
    *     because of the error above*
    Thanks&BR
    Tarek

    Hussein
    _ this  I did:_*
    **SQL> select IEM.IEM_TAG_KEYS_S1 .nextval from dual;**
    **NEXTVAL**
    **10001**
    **SQL> alter sequence IEM.IEM_TAG_KEYS_S1 increment by 1000;**
    **Sequence altered.**
    **SQL>**
    and this part from screen out put:_+
    **ATTENTION: All workers either have failed or are waiting:**
    **FAILED: file iemsvrp.odf on worker 1.**
    **ATTENTION: Please fix the above failed worker(s) so the manager can continue.**
    **Fixed: file iemsvrp.odf on worker 1 for product iem username IEM.**
    **Restarted: file iemsvrp.odf on worker 1 for product iem username IEM.**
    **FAILED: file iemsvrp.odf on worker 1 for product iem username IEM.**
    **ATTENTION: All workers either have failed or are waiting:**
    **FAILED: file iemsvrp.odf on worker 1.**
    **ATTENTION: Please fix the above failed worker(s) so the manager can continue.**
    and this from log file:+_
    **The sequence IEM_ENCRYPTED_TAG_DTLS_S1 in the database is defined as:**
    **MINVALUE = 1 MAXVALUE = 2000000000 INCREMENT BY = 1**
    **CYCLE = NO ORDER = NO CACHE = 20**
    **which should be defined as:**
    **MINVALUE = 10000 MAXVALUE = 2000000000 INCREMENT BY = 1**
    **CYCLE = NO ORDER = NO CACHE = 20**
    **Alter the sequence with :**
    **Start time for statement below is: Fri Apr 29 2011 17:10:15**
    **ALTER SEQUENCE IEM.IEM_ENCRYPTED_TAG_DTLS_S1 MINVALUE 10000**
    **AD Worker error:**
    **The following ORACLE error:**
    **ORA-04007: MINVALUE cannot be made to exceed the current value**
    **occurred while executing the SQL statement:**
    **ALTER SEQUENCE IEM.IEM_ENCRYPTED_TAG_DTLS_S1 MINVALUE 10000**
    **AD Worker error:**
    **Unable to compare or correct sequences**
    **     because of the error above**
    Thanks hussein
    please advise
    Tarek
    Edited by: user11973469 on Apr 29, 2011 5:17 PM
    Edited by: user11973469 on Apr 29, 2011 5:18 PM

  • Sequence problem plus

    Hi, I have some questions regarding sequences and more
    In short,
    I want to implement a table column that will be an autoincrement int.
    This is used as a PK to another table that holds accounting records.
    I use a cashed sequence to get autonumbers.
    Also I want this column to show always the current value of the sequence (thus the last PK used on the records table), in order to be treated like an updatable column.
    I will then implement an update trigger in the table holding the column in order for the sequence to be altered accordingly whenever an update occurs.
    So this column is behaving like a pseudocolumn.
    Can u please comment on this or give some insight on how this can be done?
    Thanks in advance,
    teo

    If you have to reset the sequence to a specific value, then the easiest way is to drop and recreate the sequence. If you increment/decrement, then the only way is that posted by Gints, that is
    ALTER SEQUENCE DSE INCREMENT BY a number
    SELECT DSE.NEXTVAL from dual
    ALTER SEQUENCE DSE INCREMENT BY 1
    If not, the increment will work at next nextval. Example :
    SCOTT@orcl SQL> create sequence s1 start with 100;
    Sequence created.
    SCOTT@orcl SQL> select s1.nextval from dual;
       NEXTVAL
           100
    SCOTT@orcl SQL> alter sequence s1 increment by 10;
    Sequence altered.
    SCOTT@orcl SQL> select s1.nextval from dual;
       NEXTVAL
           110
    SCOTT@orcl SQL> select s1.nextval from dual;
       NEXTVAL
           120
    SCOTT@orcl SQL>                                                                                        

  • Alter system archive log current

    Hi everyone,
    I write code to alter system archive log current in PL/SQL as following:
    declare
    start_sequence number;
    end_sequence number;
    begin
    --- get start sequence# ---
    select SEQUENCE# into start_sequence from v_$log where status='CURRENT';
    --- get end sequence# ---
    alter system archive log current;
    select SEQUENCE# into end_sequence from v_$log where status='CURRENT';
    end;
    When I run it, I got the following error:
    alter system archive log current;
    ERROR at line 11:
    ORA-06550: line 11, column 6:
    PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-identifier>
    <a bind variable> << close current delete fetch lock insert
    open rollback savepoint set sql execute commit forall merge
    pipe
    What does it mean? How can I fix it/
    Thanks!

    That is because you are trying to issue a DDL call in PL/SQL. The only way you can achieve this is to use DYNAMIC SQL.
    If you change your ALTER statement to:
    EXECUTE IMMEDIATE 'ALTER SYSTEM ARCHIVE LOG CURRENT';It should work.
    HTH!

  • Four fundamental questions on Sequences

    DB version:11G
    Question *1* and *2*:
    To determine the current value of a Sequence i try
    SQL> SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL;
    SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL
    ERROR at line 1:
    ORA-08002: sequence SEQ_SHP_HDR.CURRVAL is not yet defined in this
    sessionI know that if i use
    SELECT  SEQ_SHP_HDR.NEXTVAL FROM DUAL;i can get CURRVAL from the sequence. But that will increment the sequence.
    So I tried looking at user_sequences.last_number . But user_sequences.last_number was showing 552 when the actual currval was 545 !
    Why am i getting the above error (SEQ_SHP_HDR.CURRVAL is not yet defined in this session) and how can one accurately determine
    the currval of a sequence without incrementing it using NEXTVAL?
    Question *3*.
    To Increment a sequence, one should use
    alter sequence <sequencename> increment by n ;Right?
    Do you guys use
    SELECT  <sequencename>.NEXTVAL FROM DUAL;to increment SEQUENCES?
    Question *4*.
    I was trying to increment a sequence. After the ALTER statement, the sequence didn't get incremented. I had to issue a NEXTVAL call to actually get this reflected. Why is this happening?
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
    SQL> CREATE SEQUENCE myseq
      2    START WITH 1
      3    NOMAXVALUE;
    Sequence created.
    SQL> select myseq.nextval from dual;
       NEXTVAL
             1
    SQL> alter sequence myseq increment by 7;
    Sequence altered.
    SQL> select myseq.currval from dual;
       CURRVAL
             1
    SQL> select myseq.nextval from dual;
       NEXTVAL
             8
    SQL> select myseq.currval from dual;
       CURRVAL
             8
            

    Steve_74 wrote:
    DB version:11G
    Question *1* and *2*:
    To determine the current value of a Sequence i try
    SQL> SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL;
    SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL
    ERROR at line 1:
    ORA-08002: sequence SEQ_SHP_HDR.CURRVAL is not yet defined in this
    sessionI know that if i use
    SELECT  SEQ_SHP_HDR.NEXTVAL FROM DUAL;i can get CURRVAL from the sequence. But that will increment the sequence.
    So I tried looking at user_sequences.last_number . But user_sequences.last_number was showing 552 when the actual currval was 545 !
    Why am i getting the above error (SEQ_SHP_HDR.CURRVAL is not yet defined in this session) and how can one accurately determine
    the currval of a sequence without incrementing it using NEXTVAL?You cant get the CURRVAL unless you execute the NEXTVAL alteast once in your session. And you cant use the user_sequences.last_number if the CACHE is enabled.
    Question *3*.
    To Increment a sequence, one should use
    alter sequence <sequencename> increment by n ;Right?WRONG!! You have actually altered the structure of your sequence. With ALTER comand you are actually setting the increment value. Here "n" sets the increment size. If set as 1 it will increment by 1. If set as 2 will increment by 2.
    Do you guys use
    SELECT  <sequencename>.NEXTVAL FROM DUAL;to increment SEQUENCES?YES that is the correct way to increment a sequence. Use NEXTVAL to increment a sequence.
    Question *4*.
    I was trying to increment a sequence. After the ALTER statement, the sequence didn't get incremented. I had to issue a NEXTVAL call to actually get this reflected. Why is this happening?
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
    SQL> CREATE SEQUENCE myseq
    2    START WITH 1
    3    NOMAXVALUE;
    Sequence created.
    SQL> select myseq.nextval from dual;
    NEXTVAL
    1
    SQL> alter sequence myseq increment by 7;
    Sequence altered.
    SQL> select myseq.currval from dual;
    CURRVAL
    1
    SQL> select myseq.nextval from dual;
    NEXTVAL
    8
    SQL> select myseq.currval from dual;
    CURRVAL
    8
    Answer for the question 3 answers this one as well!!

  • How to leap a sequence

    hi,
    how can I leap a sequence ?
    for example: curval =100
    I want nextval = 100000
    Thanks for your help

    SQL> select s.nextval from dual;
       NEXTVAL
           100
    SQL> alter sequence s increment by 99899 -- 99899 = 100000 - 100 - 1
      2  /
    Sequence altered.
    SQL> select s.nextval from dual;
       NEXTVAL
         99999
    SQL> alter sequence s increment by 1 -- restore increment
      2  /
    Sequence altered.
    SQL> select s.nextval from dual;
       NEXTVAL
        100000
    SQL> SY.
    P.S. Nobody should be using sequence while you do the above.

  • Update a sequence

    Hi
    I have 2 DBs that looks exactly the same. They are both production versions, one is online(A) the other(B) is not. A a certian point I will export data from A and import into B. DB A will still run for a week and will of course generate new sequence numbers. After a week I will switch over to DB B, but now the sequence numbers are out of sync. Is there any way I can update a sequence? Something like':
    UPDATE sequence_name set sequence_number ='a number'.
    Thanks for your feedback.
    Regards
    Truls

    Here's another way to do it as demonstrated below:
    SQL> create sequence altest start with 1 nocache;
    Sequence created.
    SQL> select altest.nextval from dual;
    NEXTVAL
    1
    SQL> /
    NEXTVAL
    2
    SQL> alter sequence altest increment by 5; <<< you can use alter instead of drop/create or PL/SQL loop
    Sequence altered.
    SQL> select altest.nextval from dual;
    NEXTVAL
    7
    On a separate note:
    I have 2 DBs that looks exactly the same. They are both production versions, one is online(A) the other(B) is not. A a
    certian point I will export data from A and import into B.If the databases are supposed to be identical have you looked into database cloning instead of export/import. We reload
    a test database with production data every month. We used to use export/import which took 2 hours. We now use the
    cloning method and it takes 20 minutes to get an exact copy. You do have to be able to shut down the database you're
    copying though, which could be a drawback depending on your situation. If you're interested I can post more information
    about cloning here.

  • Resetting sequences....

    Hi all,
    I have this table which uses sequence as pk and somehow it went out-of-sync....i try to reset it using something like...
    alter sequence <seq_name>
    increment by 1
    minvalue <maxvalue_at_present>
    my question is
    --how a sequence went out-of-sync all of a sudden when it has the maxvalue set to 999999999999999999999999999 ???
    -- can i reset the sequence back to some mid-number....example
    say if the seq was 9000 and it got reset by next 9000 (my mistake). Now the nextval from dual is 18000. since 9000 was incremented by another 9000 which are not used, can we reset it back to 9000 and then increment it by 1 again???
    Any help is highly appreciated...thanks in advance....

    Totally agree with everyone that there really shouldn't be a need to reset sequences, but I do know when doing testing there can be circumstances when you want the sequence to start at a particular value in order to bring disperate things back into sync... so in answer to...
    can i reset the sequence back to some mid-numberYes you can...
    e.g. I want to reset my sequence to 50...
    SQL> select test.nextval from dual;
       NEXTVAL
           125
    SQL> var v_inc number;
    SQL> var v_resetno number;
    SQL> exec :v_resetno := 50;
    PL/SQL procedure successfully completed.
    SQL> exec execute immediate 'select -(test.nextval-:x)-1 from dual' into :v_inc using :v_resetno;
    PL/SQL procedure successfully completed.
    SQL> exec execute immediate 'alter sequence test increment by '||:v_inc;
    PL/SQL procedure successfully completed.
    SQL> select test.nextval from dual;
       NEXTVAL
            49
    SQL> alter sequence test increment by 1;
    Sequence altered.
    -- JOB DONE.  The sequence is now ready to use... and will start at 50...
    SQL> select test.nextval from dual;
       NEXTVAL
            50
    SQL> select test.nextval from dual;
       NEXTVAL
            51
    SQL>

  • Sequence higher number

    in a table, on cloumn is bound to a sequence. the sequence is defined to start at 1 and goes to unlimited, step 1. the last value given was 49997.
    i have delete all content from the table an inport new records. the values for the column bound to the sequence currently are 27316 to 53776. now, i can not add new records unsing the sequence, because when i ask for a new value and try to add the record, i get the ora-00001 unique constraint violation.
    how can i make the sequence to continue give values from a higher value which are not in the table now, e.g. from 54000 and up.....
    htx.
    robert

    A few options:
    - Drop the sequence and recreate using the "START WITH" clause (but this will invalidate your trigger and any code which references the sequence)
    - alter the sequence to temporarily increment it by a value which sets it to the desired value; select the next value; alter the sequence again to increment by 1
    SQL> create sequence myseq;
    Sequence created.
    SQL> select myseq.nextval from dual;
       NEXTVAL
             1
    SQL> alter sequence myseq increment by 999;
    Sequence altered.
    SQL> select myseq.nextval from dual;
       NEXTVAL
          1000
    SQL> alter sequence myseq increment by 1;
    Sequence altered.
    SQL> select myseq.nextval from dual;
       NEXTVAL
          1001

  • Sequences problem

    Hi All,
    I have a large table consisting of 3810986 rows. We have sequences generated on the primary key column(chr_val_id).
    When we do the below query
    SELECT CHR_VAL_ID_SEQ.NEXTVAL FROM DUAL we can see that the nextval is 1615. however in the table already a record is there with the same id. i assume some other operation have loaded data without using sequence.
    Now my question is, how to reset or set CURRVAL or NEXTVAL sequence value ? so that i can point it(NEXTVAL) to the latest max(chr_val_id) ??
    i have given the table structure below for your reference..
    CREATE TABLE CHR_VAL_T
      CHR_VAL_ID         NUMBER                     NOT NULL,
      CHR_VAL_CODE       NUMBER                     NOT NULL,
      CHR_ID             NUMBER                     NOT NULL,
      NUMRC_VAL          NUMBER,
      UOM_ID             NUMBER,
      DT_VAL             DATE,
      DSCR_ONLY_FLG      VARCHAR2(1 CHAR)           DEFAULT 'N'                   NOT NULL,
      CMRCLY_SNSTVE_FLG  VARCHAR2(1 CHAR)           DEFAULT 'N'                   NOT NULL,
      CPY_ITEM_VAL_FLG   VARCHAR2(1 CHAR)           DEFAULT 'N'                   NOT NULL,
      INTRNL_USE_FLG     VARCHAR2(1 CHAR)           DEFAULT 'N'                   NOT NULL,
      EXCLUDE_FROM_HDNG  VARCHAR2(1 CHAR)           DEFAULT 'N'                   NOT NULL,
      AUTO_DFLT          VARCHAR2(1 CHAR)           NOT NULL,
      AVAILABLE_FROM_DT  DATE                       NOT NULL,
      AVAILABLE_TO_DT    DATE                       NOT NULL,
      CRTD_BY            VARCHAR2(50 CHAR)          NOT NULL,
      CRTD_DTTM          DATE                       NOT NULL,
      UPD_BY             VARCHAR2(50 CHAR)          NOT NULL,
      UPD_DTTM           DATE                       NOT NULL,
      LCK_NUM            NUMBER                     NOT NULL,
      DEL_IND            VARCHAR2(1 CHAR)           DEFAULT 'N'                   NOT NULL,
      CNSLDTD_ITEM_MOD   VARCHAR2(1 CHAR)           DEFAULT 'N'                   NOT NULL,
      MOD_TYP            VARCHAR2(1 CHAR)           DEFAULT 'S'                   NOT NULL
    ALTER TABLE CHR_VAL_T ADD (
      CONSTRAINT CHR_VAL_PK_IDX
    PRIMARY KEY
    (CHR_VAL_ID));

    Hi,
    You can temporarily alter the increment of your sequence and select the nextval in order to reach your max. Then you set by you increment to the original value.
    E.g. on 10.2.0.4 database :
    SQL> create sequence s1 increment by 1;
    Sequence created.
    SQL> select s1.nextval from dual;
    NEXTVAL
    +1+
    SQL> alter sequence s1 increment by 100;
    Sequence altered.
    SQL> select s1.nextval from dual;
    NEXTVAL
    +101+
    SQL> alter sequence s1 increment by 1;
    Sequence altered.
    SQL> select s1.nextval from dual;
    NEXTVAL
    +102+
    SQL>
    Kind regards,
    Ludovic

  • Increase the MAXVALUE of a sequence...

    Hello Guys,
         I need to alter a sequence which is already in use.
    For example the existing sequence has the min value 0 and max 20. Current value is 19. I want to increase the max value to 100. Can one please let me know how I could do this without breaking the existing sequence?
    Thanks…

    There is an easy alternative. Alter the sequence' increment by clause to the required value ... do a nextval read on the sequence. Once you have the desired value alter the sequence again to reset the increment by clause.
    E.g.:
    SQL> create sequence tst_seq ;
    Sequence created.
    SQL> select tst_seq.nextval from dual ;
    NEXTVAL
    1
    SQL> alter sequence tst_seq increment by 999999 ;
    Sequence altered.
    SQL> select tst_seq.nextval from dual ;
    NEXTVAL
    1000000
    SQL> alter sequence tst_seq increment by 1 ;
    Sequence altered.
    SQL> select tst_seq.nextval from dual ;
    NEXTVAL
    1000001
    SQL>

  • Error creating repository in oracle 9i (9.2.0.1) database

    Hi I am trying to migrate a SQL Server 2000 database to oracle 9i using SQL Developer 1.5.5 and i am getting an error during the repository creation phase. I keep on having the same error:
    SQL Error on Script Execution
    Try deleting the repository before creating repository.
    And the following when i click on ok:
    The repository installation has failed. Please check the user you are registering and make sure that objects of the same name do not already exist.
    I have checked the database and both my users and temp tablespaces have more than enough space - so it is definitely not a space issue. Here are the roles and privileges that i give to the migrations user upon its creation (same from the docs):
    CREATE USER migrations_user IDENTIFIED BY migrations_user DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
    GRANT CONNECT, RESOURCE, CREATE VIEW, CREATE PUBLIC SYNONYM TO migrations_user WITH ADMIN OPTION;
    GRANT ALTER ANY ROLE, ALTER ANY SEQUENCE, ALTER ANY TABLE, ALTER TABLESPACE,
    ALTER ANY TRIGGER, COMMENT ANY TABLE, CREATE ANY SEQUENCE, CREATE ANY TABLE,
    CREATE ANY TRIGGER, CREATE ROLE, CREATE TABLESPACE, CREATE USER, DROP ANY SEQUENCE,
    DROP ANY TABLE, DROP ANY TRIGGER, DROP TABLESPACE, DROP USER, DROP ANY ROLE,
    GRANT ANY ROLE, INSERT ANY TABLE, SELECT ANY TABLE, UPDATE ANY TABLE TO migrations_user;
    Has anybody encountered this problem before and resolved it?
    Any ideas / suggestions would be greatly appreciated.
    I also tried creating the repository in a 10g database and did the migration successfully to the 9i database. However, I found out later that the created sqlserver_utilities package was invalid because it made reference to DBMS_DB_VERSION package which was non existent in the 9i database.
    Thanks
    Edited by: nyanga on Oct 2, 2009 2:20 PM
    Edited by: nyanga on Oct 2, 2009 2:22 PM

    Hi Nyanga,
    The migration tools can be used to migrate to Oracle 9i.
    But we try and keep the conversion compatible with Oracle XE / Oracle 10g and up.
    So you may have issues migrating to Oracle 9i like you said, with he sqlserver_utilities package and using 10g syntax.
    Creating the repository on Oracle 9i is not supported.
    But even if you did succeed , it would not change how the conversion was done. You would still end up with an identical sqlserver_utilities package which was generated using the migration repository on an Oracle 10g database. sqlserver_utilities package definition itself is fixed within a file so regardless of the repository used the same one will be generated.
    Oracle XE can be used of course as the repository and its free to download and use.
    Regards,
    Dermot.

  • SQL SERVER 2005 to Oracle 10g r 2

    Hi all,
    I'm getting an "error" when I'm trying to convert a sql server 2005 database to a oracle 10g database.
    It seems to be right in te convert step:
    Copying Model:     1
    Transforming identifiers: 1
    Transformation Result: 16
    Transformed successfully:     1
    but there is no converted model and no log registries.
    the migrations user roles and privileges are:
    GRANT CONNECT, RESOURCE, DBA,
    ALTER ANY TRIGGER, CREATE ROLE, CREATE SESSION, CREATE USER, CREATE VIEW, CREATE PUBLIC SYNONYM
    TO migrations WITH ADMIN OPTION;
    GRANT ALTER ANY ROLE, ALTER ANY SEQUENCE, ALTER ANY TABLE, ALTER TABLESPACE,
    COMMENT ANY TABLE, CREATE ANY SEQUENCE, CREATE ANY TABLE,
    CREATE ANY TRIGGER, CREATE TABLESPACE, DROP ANY
    SEQUENCE, DROP ANY TABLE, DROP ANY TRIGGER, DROP TABLESPACE, DROP USER, DROP ANY
    ROLE, GRANT ANY ROLE, INSERT ANY TABLE, SELECT ANY TABLE, UPDATE ANY TABLE TO
    migrations;
    And I'm using Sql Developer Version 2.1.1.64 in a Win XP 64bits computer
    Could you please help me with this problem...
    Thanks,
    Manuel

    Manual,
    Do you see the same problem if you try the migration in stages ?
    Could you -
    - click on the SQL*Server database to be migrated and choose 'Capture Microsoft SQL*Server'
    - does that complete successfully ?
    - if right click on the captured model and choose 'Show log messages' is anything displayed ?
    - if the capture is okay, then right click and choose 'Convert to Oracle Model'
    - does this create a converted model ? If you right click and choose 'Show log messages' is anything displayed ?
    if you still have problems could you try deleting the migration repository then creating a new one ?
    Regards,
    Mike

  • Error in the procedure while tried to increment the seq

    Hello ,
    I tried the following but giving the errors..
    Plz help me in this..
    CREATE OR REPLACE PROCEDURE Seq_inc AS
       vmaxarrec number(10);
       vseq number(10);
          select max(recid) into vmaxarrec from acc_rec;
          select SEQ_ACC_REC.currval into vseq from dual;
        BEGIN
          FOR i IN vseq .. vmaxarrec  LOOP
            select SEQ_ACC_REC.nextval  from dual;
          END LOOP;
        END ;And giving the following errors...
    LINE/COL ERROR
    4/7 PLS-00103: Encountered the symbol "SELECT" when expecting one of
    the following:
    begin function package pragma procedure subtype type use
    <an identifier> <a double-quoted delimited-identifier> form
    current cursor
    The symbol "begin" was substituted for "SELECT" to continue.
    11/9 PLS-00103: Encountered the symbol "end-of-file" when expecting
    one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    LINE/COL ERROR
    <an identifier> <a double-quoted delimited-identifier>
    <a bind variable> << close current delete fetch lock insert
    open rollback savepoint set sql execute commit forall merge
    Thanks

    smile wrote:
    SQL> CREATE OR REPLACE PROCEDURE Seq_inc AS
    2     vmaxarrec number(10);
    3     vseq number(10);
    4       
    5      BEGIN   
    6      select max(recid) into vmaxarrec from acc_rec;
    7      select SEQ_ACC_REC.currval into vseq from dual;
    8       
    9        FOR i IN vseq .. vmaxarrec  LOOP
    10          select SEQ_ACC_REC.nextval  from dual;
    11        END LOOP;
    12   
    13      END ;
    14  /
    Warning: Procedure created with compilation errors.
    SQL> sho err
    Errors for PROCEDURE SEQ_INC:
    LINE/COL ERROR
    10/9     PLS-00428: an INTO clause is expected in this SELECT statementI tried with the above correction ..and still errorsIt looks to me like you're trying to reset the sequence number to a new starting value. In reality there's very little point in doing this, though I've come across a few test scenarios where it's good to start with the same sequence number each time.
    The logic for changing a sequence to a particular value is along the lines of:
    SQL> select test.nextval from dual;
       NEXTVAL
           125
    SQL> var v_inc number;
    SQL> var v_resetno number;
    SQL> exec :v_resetno := 50;
    PL/SQL procedure successfully completed.
    SQL> exec execute immediate 'select -(test.nextval-:x)-1 from dual' into :v_inc using :v_resetno;
    PL/SQL procedure successfully completed.
    SQL> exec execute immediate 'alter sequence test increment by '||:v_inc;
    PL/SQL procedure successfully completed.
    SQL> select test.nextval from dual;
       NEXTVAL
            49
    SQL> alter sequence test increment by 1;
    Sequence altered.
    SQL> select test.nextval from dual;
       NEXTVAL
            50
    SQL> select test.nextval from dual;
       NEXTVAL
            51
    SQL>Note: In your code you are reading the currval of the sequence before you know that you've read the nextval. That will give an error, because the currval is only known within the current session after a nextval has been obtained.
    So, as a procedure, you want something like:
    CREATE OR REPLACE PROCEDURE Seq_inc AS
      v_maxarrec number;
      v_inc      number;
      v_seq      number;
    BEGIN   
      select max(recid)+1 into v_maxarrec from acc_rec; -- get the required sequence value
      select -(seq_acc_rec.nextval-v_maxarrec)-1 into v_inc from dual; -- determine the difference
      execute immediate 'alter sequence seq_acc_rec increment by '||v_inc; -- alter the sequence
      select seq_acc_rec.nextval into v_seq from dual; -- query the sequence to reset it
      execute immediate 'alter sequence seq_acc_rec increment by 1'; -- alter the sequence to increment by 1 again
    END ;(+untested+)

Maybe you are looking for