Insert Select sequence.nextval Problme

Hi,
I am trying to insert records in the table using query similar to
insert into table1 (id, col1, col2)
select
sequence.nextval
t1. col1, t1.col2
from table t1;
I am getting following error
ORA-02287: sequence number not allowed here
Will you please let me know how to resolve this?
Regards
~Pravin

Hmm...
See here ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>
satyaki>create table ff_gg
  2      (
  3        a_col   number(5),
  4        b_col   varchar2(30)
  5      );
Table created.
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>create sequence dd_qq
  2     start with 1
  3     increment by 1;
Sequence created.
Elapsed: 00:00:00.00
satyaki>
satyaki>insert into ff_gg
  2     select rn, ename
  3     from (
  4            select dd_qq.nextval, ename
  5            from emp
  6          );
          select dd_qq.nextval, ename
ERROR at line 4:
ORA-02287: sequence number not allowed here
Elapsed: 00:00:00.00
satyaki>
satyaki>ed
Wrote file afiedt.buf
  1  insert into ff_gg
  2     select dd_qq.nextval rn, ename
  3     from (
  4            select ename
  5            from emp
  6*         )
satyaki>/
12 rows created.
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from ff_gg;
     A_COL B_COL
         1 WARD
         2 MARTIN
         3 SCOTT
         4 KING
         5 TURNER
         6 ADAMS
         7 JAMES
         8 FORD
         9 MILLER
        10 Smith
        11 Glen
     A_COL B_COL
        12 boock
12 rows selected.
Elapsed: 00:00:00.00
satyaki>Got me?
Regards.
Satyaki De.

Similar Messages

  • Please Help me with long time oracle  select sequence.nextval from dual

    Hi
    I'm in a real problem.In fact i have a J2EE5(JPA,Hibernate 3,EJB 3.0) project deployed at websphere 6 application server and i'm using Oracle 10 g R2.
    Well i have a batch job that inserts into some table called AVERAGEBALANCE.
    the problem is that when i have activated hibernate log i discoverd that the select from dual is the longest sql (it takes some times over second !!)
    here is the log
    11/07/2011 08:49:40,406 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - insert into AVERAGEBALANCE (CDATE_, CUSER_, AVERAGEBALANCE_, AVERAGECREDITORBALANCE_, AVERAGEDEBITORBALANCE_, BEGINDATE_, CALCULATIONDATE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, ENDDATE_, NBCREDITORDAYS_, NBDEBITORDAYS_, TEDABCALCULATIONPERIODICITYPK_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    11/07/2011 08:49:40,468 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - select this_.PK_ as PK1_465_0_, this_.CDATE_ as CDATE2_465_0_, this_.CUSER_ as CUSER3_465_0_, this_.UUSER_ as UUSER4_465_0_, this_.BALANCE_ as BALANCE5_465_0_, this_.BALANCETYPE_ as BALANCET6_465_0_, this_.CASHSUBACCOUNTPK_ as CASHSUBA8_465_0_, this_.CASHSUBACCOUNTCODE_ as CASHSUBA7_465_0_, this_.CODE_ as CODE9_465_0_, this_.CURRENCYPK_ as CURRENCYPK11_465_0_, this_.CURRENCYCODE_ as CURRENC10_465_0_, this_.ENDDATE_ as ENDDATE12_465_0_, this_.EXCHANGERATE_ as EXCHANG13_465_0_, this_.ORIGINBALANCEPK_ as ORIGINB15_465_0_, this_.ORIGINBALANCECODE_ as ORIGINB14_465_0_, this_.POSITIONDATE_ as POSITIO16_465_0_, this_.REVALUATIONDATE_ as REVALUA17_465_0_, this_.SUMOFCREDITS_ as SUMOFCR18_465_0_, this_.SUMOFDEBITS_ as SUMOFDE19_465_0_, this_.UDATE_ as UDATE20_465_0_, this_.VERSIONNUM_ as VERSIONNUM21_465_0_ from CASHAB this_ where this_.CASHSUBACCOUNTCODE_=? and this_.BALANCETYPE_=? and this_.POSITIONDATE_<? and this_.ENDDATE_>=? and this_.BALANCE_<>?
    11/07/2011 08:49:40,468 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - select AVERAGEBALANCE_.nextval from dual
    11/07/2011 08:49:41,484 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - insert into AVERAGEBALANCE (CDATE_, CUSER_, AVERAGEBALANCE_, AVERAGECREDITORBALANCE_, AVERAGEDEBITORBALANCE_, BEGINDATE_, CALCULATIONDATE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, ENDDATE_, NBCREDITORDAYS_, NBDEBITORDAYS_, TEDABCALCULATIONPERIODICITYPK_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)well i have increased the sequence cache in fact here is the creation code of the sequence.
    CREATE SEQUENCE  "COMPTAPERF5"."AVERAGEBALANCE_"  MINVALUE 1 MAXVALUE 999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 400 NOORDER  NOCYCLE   ;i think that there is some oracle parameter to tune
    Thanks in advance
    Edited by: B.Mansour Nizar on 11 juil. 2011 01:04
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:33
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:34
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:34
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:35
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:35
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:36
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:42

    I found it.
    It's not due to oracle but it's a hibernate issue.In fact if setting FlushMode to Manual.It wil flush the in memory entities after that it will fire the insert statement.
    Here's the log.
    15/07/2011 15:32:47,984 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - select CASHAB_.nextval from dual
    15/07/2011 15:32:47,984 TRACE AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - preparing statement
    15/07/2011 15:32:47,984 DEBUG SequenceGenerator:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Sequence identifier generated: 20441
    15/07/2011 15:32:47,984 DEBUG AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    15/07/2011 15:32:47,984 TRACE AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - closing statement
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - aggressively releasing JDBC connection
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    15/07/2011 15:32:47,984 DEBUG AbstractSaveEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - generated identifier: 20441, using strategy: org.hibernate.id.SequenceHiLoGenerator
    15/07/2011 15:32:47,984 TRACE AbstractSaveEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - saving [com.bfi.cpt.bal.cas.CashAccountingBalance#20441]
    15/07/2011 15:32:47,984 TRACE Versioning:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - using initial version: 0
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - flushing session
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing flush-time cascades
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.cht.cas.CashSubAccount
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.cht.cas.CashSubAccount
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.ref.cur.Currency
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.ref.cur.Currency
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.bal.cas.CashAccountingBalance
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.bal.cas.CashAccountingBalance
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - dirty checking collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushing entities and processing referenced collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Processing unreferenced collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Scheduling collection removes/(re)creates/updates
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushed: 1 insertions, 0 updates, 0 deletions to 3 objects
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - listing entities:
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.ref.cur.Currency{translatedName=null, certain=false, iso3166=788, quotity=1, identifier=TND, creationUser=admin, internalCode=null, name=Dinars Tunisien, creationDate=2011-07-11 14:43:06, code=TND, versionNum=0, decimal=3, updateUser=null, updateDate=null, pk=136, decimalName=millimes}
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.cpt.bal.cas.CashAccountingBalance{cashSubAccount=com.bfi.cpt.cht.cas.CashSubAccount#400201, originBalanceCode=null, exchangeRate=null, sumOfDebits=0.0, endDate=31 décembre 9999, creationUser=bna, currencyPk=136, creationDate=2011-07-15 15:32:47, cashSubAccountCode=BNA/PCI_BNA/82-TND, code=2010-07-30/BNA/PCI_BNA/82-TND/AccountingDateBalance/TND, versionNum=0, originBalancePk=null, currency=com.bfi.ref.cur.Currency#136, updateUser=null, originBalance=null, balanceType=AccountingDateBalance, updateDate=null, positionDate=30 juillet 2010, sumOfCredits=10.0, pk=20441, cashSubAccountPk=400201, revaluationDate=null, balance=-10.0, currencyCode=TND}
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.cpt.cht.cas.CashSubAccount{name2=null, accountPk=81, name=null, versionNum=0, currency=com.bfi.ref.cur.Currency#136, updateDate=null, chartByEntity=com.bfi.cpt.cht.std.ChartByEntity#2, refAccount=null, currencyCode=TND, chartByEntityCode=BNA/PCI_BNA, refAccountCode=null, creationDate=2011-07-15 15:25:45, account=com.bfi.cpt.cht.cas.StandardAccount#81, freeKey10=null, freeKey11=null, chartByEntityPk=2, freeKey12=null, updateUser=null, refAccountPk=null, freeKey13=null, freeKey14=null, freeKey15=null, freeKey16=null, freeKey17=null, accountCode=PCI_BNA/81, freeKey18=null, freeKey19=null, freeKey0=null, freeKey1=null, freeKey2=null, freeKey3=null, freeKey4=null, freeKey5=null, freeKey6=null, freeKey7=null, freeKey8=null, freeKey9=null, number=82-TND, creationUser=bna, freeKey20=null, freeKey21=null, freeKey22=null, freeKey23=null, freeKey24=null, freeKey25=null, freeKey26=null, freeKey27=null, freeKey28=null, freeKey29=null, currencyPk=136, code=BNA/PCI_BNA/82-TND, freeKey30=null, freeKey31=null, freeKey32=null, pk=400201}
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - executing flush
    15/07/2011 15:32:47,984 TRACE ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - registering flush begin
    15/07/2011 15:32:47,984 DEBUG UpdateTimestampsCache:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Pre-invalidating space [CASHAB]
    15/07/2011 15:32:47,984 TRACE AbstractEntityPersister:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Inserting entity: [com.bfi.cpt.bal.cas.CashAccountingBalance#20441]
    15/07/2011 15:32:47,984 TRACE AbstractEntityPersister:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Version: 0
    15/07/2011 15:32:47,984 DEBUG AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - opening JDBC connection
    15/07/2011 15:32:47,984 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - insert into CASHAB (CDATE_, CUSER_, BALANCE_, BALANCETYPE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, CURRENCYCODE_, CURRENCYPK_, ENDDATE_, POSITIONDATE_, SUMOFCREDITS_, SUMOFDEBITS_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)Edited by: B.Mansour Nizar on 15 juil. 2011 07:38
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:39
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:43

  • Inserting oracle sequence values

    hI
    Do i need to do a select sequence.nextval from dual
    before i insert the next sequence value into the table
    For eg i tried using the foll insert statement but i get an invalid number exception
    insert into parts(PARTS'DATABASE.PARTNOSEQ.NEXTVAL',"+PARTNO+")
    But i get the above exception.I dont do a select now.
    Thanks
    Arn

    Hi
    I tried doing the following trying to insert sequence values but I still get an invalid get Column error.
    sql4 = "select PART_SEQ.NEXTVAL FROM DUAL";
    ResultSet rs3 = stmt2.executeQuery(sql4);
    while (rs3.next())
    seqVal = rs.getInt("PART_SEQ");
    rs3.close();
    for(int i=0; i<=count; i++)
    { // for loop
         sql3 = "Update part " +
         " SET part_mfr = '"+mfgcodeStr+"' ,
         " part_id = "+seqVal+"," +
         " WHERE invoiceno = '"+invoicenoStr+"' ";
    Thanks
    arn

  • Passing sequence nextval in insert statement

    Hi,
    Want to insert a record in table A using incremented sequence value to be get inserted in the ID column of table.
    ID column is having a primary key constraint
    created sequence test1_seq for that table
    How to use this sequence number's NEXTVAL to be get inserted in ID column of table A, along with other data.
    How to pass the values to the below procedure for inserting record ?
    There are total six fields in the column
    execute pk_test1.insert_test1('*How to pass next sequence value here ?*','rec2','rec3','rec4','rec5','rec6')
    With Regards
    Edited by: user640001 on Aug 10, 2010 12:25 AM

    Check this: You can create a trigger to insert a sequence value in to a table for every insert that happens:
    SQL> create table my_Test1(col1 number,col2 VARCHAR2(100));
    Table created.
    SQL> ed
    Wrote file afiedt.buf
      1  create sequence test1_seq
      2  start with 1
      3  increment by 1
      4  maxvalue 999999999
      5  nocycle
      6  nocache
      7* noorder
    SQL> /
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace package pkg1_test as
      2  procedure insert_tab1(p_val1 VARCHAR2);
      3* end;
    SQL> /
    Package created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace package body pkg1_test as
      2  procedure insert_tab1(p_val1 varchar2) is
      3  begin
      4  insert into my_test1(col2) values(p_val1);
      5  COMMIT;
      6  END;
      7* end;
    SQL> /
    Package body created.
    SQL> create trigger my_trig1 before insert on my_test1
      2  for each row
      3  declare
      4  v_seqno NUMBER := 0;
      5  BEGIN
      6  SELECT test1_seq.nextval into v_seqno from dual;
      7  :new.col1 := v_seqno;
      8  end;
      9  /
    Trigger created.
    SQL> exec pkg1_test.insert_tab1(100);
    PL/SQL procedure successfully completed.
    SQL> select * from my_Test1;
          COL1 COL2
             1 ABCD
             2 100
    SQL> select test1_seq.currval from dual;
       CURRVAL
             2
    SQL> Edited by: AP on Aug 10, 2010 12:38 AM

  • Goldengate replicat slow to process sequence.nextval

    GGS replicat takes 45 minutes to process this statement. Tracing the replicat session shows that replicat is continuously altering the sequence on the target. The statement completes on the source in less than 1 minute. Any ideas on how I can speed this up.
    Thanks,
    Lynn
    insert into test_tab2
    select MYSEQ_ID.nextval,OR_DATETIME_ID,LOCATION_ID, CLINIC_ID ,ACCESSION_COUNTS
    from
    (select * from summary.CLINIC_MV
    where order_datetime_id >
    (select mor_datetime_id) - 40 from summary.CLINIC_MV))

    Identified OS issue. Not a GGS issue.

  • Select sequences number in a Query

    I am facing problems while selecting the Sequence Number in a query.
    create or replace view vfilemanifest as
    (select abc.* , ts.* from (select filemanifestid.nextval from dual) abc ,
    ( select distinct batchid,custodianid from
    tbatch tbat ,tcustodians tcstd, EXT_TAB_MASTERS ext_tab
    where tbat.batchname = ext_tab.batchname
    and tbat.batchpath = ext_tab.batchpath
    and tcstd.custodianname = ext_tab.custodianname
    and tcstd.custodianadd = ext_tab.custodianadd
    )ts )
    SQL> /
    (select abc.* , ts.* from (select filemanifestid.nextval from dual) abc ,
    ERROR at line 2:
    ORA-02287: sequence number not allowed here
    Please Advice
    Regards
    Sushant

    I'm sorry but that doesn't make it any clearer to me. This
    using External Tables , View , Collection , bulk collect and Forall Insert is an implementation, not a business requirement. You might find some enlightenment in want to create a pl/sql table type dynamically I answered.
    Anyway, I think what you want to do is this: (warning, untested code ahead!)
    DECLARE
       TYPE lrec IS RECORD (
           id NUMBER,
           batchid tbatc.batchid%TYPE,
           custodianid tcustodians.custodianid%TYPE);
       TYPE ltab IS TABLE OF lrec;
       llist ltab;
    BEGIN
       SELECT abc.* , ts.* BULK COLLECT INTO llist
       FROM  (select filemanifestid.nextval from dual) abc
             , ( select distinct batchid,custodianid
                 from   tbatch tbat ,tcustodians tcstd, EXT_TAB_MASTERS ext_tab
                 where tbat.batchname = ext_tab.batchname
                 and tbat.batchpath = ext_tab.batchpath
                 and tcstd.custodianname = ext_tab.custodianname
                 and tcstd.custodianadd = ext_tab.custodianadd
               )ts 
    END;
    /Cheers, APC

  • Oracle native sequencing: nextVal executed two times.

    We are migrating from Weblogic 6.1 sp 5 & TopLink 3.6.3 to Weblogic 8.1 sp 2 & TopLink 9.0.4 and we are having this issue:
    It seems that when assigning the sequence to new objets TopLink execs the nextVal for the sequence twice. In fact we probably wouldn't notticed it if it was just that, the problem is that TopLink seems to register the object into the cache with an oid and assigning the next one to the object stored in the database so we are getting NoSuchObjectException each time we try to access them.
    Here is a dump of TopLink's log showing the problem:
    [TopLink]: ServerSession(22807116)--Connection(0)--client acquired
    [TopLink]: ClientSession(25858791)--Connection(0)--acquire unit of work: 10772417
    [TopLink]: UnitOfWork(10772417)--Connection(0)--JTS register
    [TopLink]: ServerSession(22807116)--Connection(17740413)--SELECT SEQ_BOOK.NEXTVAL FROM DUAL
    [TopLink]: ServerSession(22807116)--Connection(17558511)--SELECT SEQ_PAGE.NEXTVAL FROM DUAL
    [TopLink]: UnitOfWork(10772417)--Connection(0)--Before JTS Completion
    [TopLink]: UnitOfWork(10772417)--Connection(25919386)--Begin batch statements
    [TopLink]: UnitOfWork(10772417)--Connection(25919386)--INSERT INTO AUTHOR (NAME, OCA, OID) VALUES (?, ?, ?)
    [TopLink]: UnitOfWork(10772417)--Connection(0)-- bind => [Roger Penrose, 2004-05-11 18:54:01.917, 442803]
    [TopLink]: UnitOfWork(10772417)--Connection(25919386)--End Batch Statements
    [TopLink]: ClientSession(25858791)--Connection(25919386)--Begin batch statements
    [TopLink]: ClientSession(25858791)--Connection(25919386)--INSERT INTO BOOK (NAME, OCA, OID, OID_AUTHOR) VALUES (?, ?, ?, ?)
    [TopLink]: ClientSession(25858791)--Connection(0)-- bind => [The Emperor's New Mind, 2004-05-11 18:54:01.92, 347404, 442803]
    [TopLink]: ClientSession(25858791)--Connection(0)-- bind => [Shadows of the Mind, 2004-05-11 18:54:01.943, 347405, 442803]
    [TopLink]: ClientSession(25858791)--Connection(25919386)--End Batch Statements
    [TopLink]: UnitOfWork(10772417)--Connection(0)--After JTS Completion
    [TopLink]: UnitOfWork(10772417)--Connection(0)--release unit of work
    [TopLink]: ClientSession(25858791)--Connection(0)--client released
    [TopLink]: ServerSession(22807116)--Connection(0)--client acquired
    [TopLink]: ClientSession(116689)--Connection(0)--acquire unit of work: 32580168
    [TopLink]: UnitOfWork(32580168)--Connection(0)--JTS register
    [TopLink]: UnitOfWork(32580168)--Connection(0)--Before JTS Completion
    [TopLink]: UnitOfWork(32580168)--Connection(17129104)--Begin batch statements
    [TopLink]: UnitOfWork(32580168)--Connection(17129104)--INSERT INTO AUTHOR (NAME, OCA, OID) VALUES (?, ?, ?)
    [TopLink]: UnitOfWork(32580168)--Connection(0)-- bind => [Benoit Mandelbrot, 2004-05-11 18:54:49.264, 442805]
    [TopLink]: UnitOfWork(32580168)--Connection(17129104)--End Batch Statements
    [TopLink]: ClientSession(116689)--Connection(17129104)--Begin batch statements
    [TopLink]: ClientSession(116689)--Connection(17129104)--INSERT INTO BOOK (NAME, OCA, OID, OID_AUTHOR) VALUES (?, ?, ?, ?)
    [TopLink]: ClientSession(116689)--Connection(0)-- bind => [Les objets fractals, forme, hasard et dimension, 2004-05-11 18:54:49.266, 347409, 442805]
    [TopLink]: ClientSession(116689)--Connection(0)-- bind => [The Fractal Geometry of Nature, 2004-05-11 18:54:49.282, 347408, 442805]
    [TopLink]: ClientSession(116689)--Connection(17129104)--End Batch Statements
    [TopLink]: UnitOfWork(32580168)--Connection(0)--After JTS Completion
    [TopLink]: UnitOfWork(32580168)--Connection(0)--release unit of work
    [TopLink]: ClientSession(116689)--Connection(0)--client released
    the test is about creating two objects (well, we are actually creating 6 objects in this sample as we are creating two "master" objects and adding two related (in a one to many relationship) objects to each one.)
    The thing I would like you to notice is this:
    The first AUTHOR object gets assigned the OID 442803 wether the next AUTHOR object gets the OID 442805 although we expected it to be 442804.
    The same occurs with the objects in the "many" side of the relation. They get sibiling OIDs but with a gap of two OIDs when creating the last two.
    I have been searching for simmilar problems in this forums and I found two posts:
    Both where related to a bug of an older version of TopLink (9.0.3 I think) when using something different than a number for the sequence field of an object. I expect it to be fixed in 9.0.4 version as it seemed to be fixed even for the 9.0.3 version. May it be a regression bug?
    Anyway, we are using BigDecimal on entity bean's sequence number and IIRC NUMBER(18) in Oracle tables.
    Currently our TopLink version is: 9.0.4 (031126)
    Our native sequence has an allocation size of 200 and it matches with SEQUENCEs defined in Oracle.
    As we are migratting from TopLink 3.6.3 and we have not changed the sequence prealocation size (we have not touched the database at all) we don't expect the problem to be on sequence prealocation.
    I must say we have changed the "default" JDBC driver that TopLink uses when doing the issuing the loging phase (which I think is a SUN driver) to an oracle.jdbc.driver.OracleDriver as we were having problems with timestamp locking.
    Any idea?
    Thanks in advance.
    Ignacio.

    Solved!
    It was my fault. I was doing a really nasty thing to the entity beans.
    I must publicly thank my work mate (which is a pretty smart girl, I must say) in tracking down this issue.
    Here is what (we think) was happening:
    As I told in previous post in this post we are in the process of moving from TopLink 3.6.3 (EJB 1.1) to TopLink 9.0.4 (EJB 2.0). We do have a "super class" in our application where we had some common things of our entity beans, i.e. entityContext, oid and oca attributes. We have also some methods that retrieve and set values from and to the entity beans via value objects (in order to avoid the heavy RMI operations when doing it through "standard" getters and setters) well, it happened that the current implementation of the "batch setting" method used the getDeclaringMethods to update in both UPDATE and INSERT opperations entity attributes with the data of the value object.
    When switching to EJB 2.0 we had to push down both the oid and oca attributes (in order of being able do deploy them) to each final entity bean and now they where being included in the setting process!
    You can imagine an scenario like this:
    1. ejbCreate() // TopLink issues the SELECT SEQ_XXX NEXT VAL FROM DUAL and sets the oid of the EJB
    2. setAttributes() // transfer info from the value object to the newly created EJB: including a setOid(null)!
    3. commit() (Before Completion)
    4. TopLink detects that the damm object surprisingly DOES NOT have the oid attribute setted so it performs another SELECT SEQ_XXX NEXT VAL FROM DUAL in order to "fix" this big problem.
    5. commit() (After Completion) // the object is written to the database with the second value from the sequence whereas the first value is used to identify the entity bean into the identity cache.
    Well it may not be "exactly" what is happening but I'm sure we are not so far from reality with our assumptions.
    Andrei Ilitchev, thanks for your interest, sorry I could not post this sooner.

  • Insert the sequence number in table

    Hi..i created one table and i want to insert the sequence num in one column using sql query is it possible? please help me

    Try this..
    SQL> create table t1(x number);
    Table created.
    SQL> create sequence seq_x;
    Sequence created.
    SQL> insert into t1 values(seq_x.nextval);
    1 row created.
    SQL> /
    1 row created.
    SQL> /
    1 row created.
    SQL> /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
    X
    1
    2
    3
    4

  • Problem inserting auto-sequence for PK value using trigger - ORA-02287

    I have a query where the sub-query is working. I created a table to receive the results of the query. I created a Sequence:
    CREATE SEQUENCE SEQ_RPT_H2_LOOPS
    MINVALUE 1
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE;
    Then I created a trigger:
    CREATE OR REPLACE TRIGGER TRG_RPT_H2_LOOPS
    BEFORE INSERT ON RPT_H2_LOOPS
    FOR EACH ROW
    BEGIN
    SELECT SEQ_RPT_H2_LOOPS.NEXTVAL INTO :NEW.RECORD_ID FROM DUAL;
    END;
    And here is the Insert query.
    accept month_year;
    accept prior_month_year;
    insert into rpt_h2_loops (
         RECORD_ID,
         MKT_CODE,
         MKT_NAME,
         ECCKT,
         VENDOR_ID,
         ECCKT_VENDOR_ID,
         OCN,
         FAC_TYP,
         ALOC,
         ZLOC,
         STATE,
         OCN_STATE,
         OCN_STATE_COLO,
         SRVC_TYP,
         CUR_PERIOD,
         PRIOR_PERIOD,
         TIME_STAMP )
    select seq_rpt_h2_loops.nextval
    ,substr(r.sub_acct,4,3)
    ,m.market
    ,rr.ckt
    ,rr.vendor_id
    ,rr.ckt||rr.vendor_id
    ,rr.ocn
    ,rr.srvc_typ
    ,'N/A'
    ,rr.zloc
    ,rr.st_cd
    ,rr.ocn||rr.st_cd
    ,rr.ocn||rr.st_cd||rr.zloc
    ,rr.srvc_typ
    ,'&month_year'
    ,'&prior_month_year'
    ,sysdate
    from rco.rate_route rr
    ,rco.cogs_resource r
    ,rco.cogs_mkt m
    where rr.cvbi_key = r.cvbi_key
    and     m.subacct = r.sub_acct
    and     to_char(rr.period, 'mm/yyyy') = '&month_year'
    and     to_char(r.period, 'mm/yyyy') = '&month_year'
    and     rr.srvc_typ = 'CUNE'
    group by    substr(r.sub_acct,4,3)
    ,m.market
    ,rr.ckt
    ,rr.vendor_id
    ,rr.ckt||rr.vendor_id
    ,rr.ocn
    ,rr.srvc_typ
    ,rr.zloc
    ,rr.st_cd
    ,rr.ocn||rr.st_cd
    ,rr.ocn||rr.st_cd||rr.zloc
    );The problem is that I am getting a ORA-02287: sequence number not allowed here on the NEXTVAL keyword.
    The sequence and trigger compiled without problem. I just can't seem to insert that value into the query. Any help would be appreciated.

    you are defeating the purpose of trigger which is before insert so just rewrite the query and remove the column for which value will be inserted using the created sequence and your code will work.
    Regards,
    Vikas Kumar

  • To access a sequence.nextval from Infobus applet

    Hi
    I have Infobus Dataform applet which displays the columns of the
    table - timesheets which has a column "line_item" which has to
    get it's value from a database sequence.
    So I followed the approach followed in the Acme - sample
    application ViewMembers.java.
    Which the row added event of the RowsetInfo -
    The following code was added with my Rowset and sequence used.
    void ACME_MEMBERSIter_rowAdded(RowChangeEvent e) throws
    java.sql.SQLException,
    javax.infobus.DuplicateColumnException,
    javax.infobus.ColumnNotFoundException,
    javax.infobus.InvalidDataException
    RowsetAccess rsa = e.getDataItem();
    DbAccess dba = rsa.getDb();
    RowsetAccess seq = null;
    seq = (RowsetAccess)dba.executeRetrieval(
    "select acme_member_id_seq.nextval as
    \"new_id\" from dual",
    "infobus:/oracle/sessionInfo1/new_id",
    null);
    ImmediateAccess nv = null;
    ImmediateAccess column_id = null;
    nv = (ImmediateAccess)seq.getColumnItem("new_id");
    column_id = (ImmediateAccess)rsa.getColumnItem
    ("MEMBER_ID");
    column_id.setValue(nv.getValueAsString());
    This does not work when I run it from Jdeveloper I have debugged
    it an umpteen times and still no clue.
    The statement
    (RowsetAccess)dba.executeRetrieval(
    "select acme_member_id_seq.nextval as
    \"new_id\" from dual",
    "infobus:/oracle/sessionInfo1/new_id",
    null);
    JUST DOES NOT WORK.
    Please help.
    Regards
    Rajs
    null

    Hi Shachar,
    When SEQUENCE_SETUP/RESETUP is called, I need to modify the arbitrary data.
    Arbitrary data can be accessed in 2 ways (as per my knowledge)
    1. GetNewStreamValue() & SetStreamValue() (for this I need AEGP_EffectRef which will be NULL for the new effect when it comes to SEQUENCE_SETUP/RESETUP).
    2. If PF_ParamDef* params is not NULL then,
         PF_Handle                arbH        = params[PARAM_ID]->u.arb_d.value;
        CG_ArbData                *arbP;
        arbP    = reinterpret_cast<CG_ArbData*>(PF_LOCK_HANDLE(arbH));
    In the first way, when SEQUENCE_SETUP/RESETUP is called AEGP_EffectRef is NULL, so I cannot use it.
    In the second way, when SEQUENCE_SETUP/RESETUP is called  PF_ParamDef* params is NULL, so I cannot use it.
    Any ideas?

  • Insert-request & sequence values

    Trying to employ a seq value (not null, key field) along with insert-request causes ORA-01400. Current transform produces:
    <field1>sequencename.NEXTVAL</field1>
    <field2>fieldvalue1</field2>
    <fieldn>fieldvaluen</fieldn>
    Since I don't know how many rows will be inserted, I can't really select sequencename.NEXTVAL from dual.
    Any suggestions?
    JV

    ok, we figured it out. make certain your before-insert trigger is properly established, and make no reference whatsoever to that column in your transform.xsl that is used in conjunction with the insert-request.
    As the insert-request performs the insert (presumably the same for update-request), the trigger will obtain the next seqval, and the transform, if properly formed in canonical format, will pass the xml tree to the insert-request and the fields will be inserted "clean as a whistle".!

  • How can i insert pseudocolumn (sequencename.nextval) with oracleXmlSave?

    how can i insert pseudocolumn value (sequencename.nextval) with oracleXmlSave.insertXml(xmlfile)?
    if anyone know it, pls post the answer to the bbs or reply me: [email protected]
    thank u so much.

    You can create a trigger on the table and insert your sequence no from there or create a updateable view and create insted off trigger to populate your columns. I am new to XML, but I think this the way you can do it esealy. Or may be this the only way.

  • Sequence.nextval doubles the returned value with Execute Statement (F9)

    There appears to be a quirk with sequences in Raptor.
    Has anyone noticed that depending on how you execute this sql (SELECT MYSEQ.NEXTVAL FROM DUAL;) the value returned is either the correct nextval or double what you expected?
    For example, MYSEQ is a simple sequence which increments by 1. If you Execute Statement (F9) then the value returned jumps by 2 instead of 1. If you Run Script (F5) then the value returns jumps by 1, as expected.
    If MYSEQ is changed to increment by 2. The when you Execute Statement (F9) then the value returned jumps by 4 instead of 2. If you Run Script (F5) then the value returns jumps by 2, as expected. No matter what you put for the increment by Execute Statement (F9) always doubles it.
    It always seems to be double. Executing the same scenario in TOAD always returns the correct value (i.e. properly increments).
    Is the query being executed multiple times with Execute Statement? Why is this happening?

    While there is no guarantee from Oracle that sequences produce sequential numbers, this is obviously a case where SQL Developer is running the select statement twice.
    The issue is that queries can actually change information, rather than just retrieve data from the database.
    The following package is a test case:
    create or replace package test_query is
    function get_next_count return number;
    end;
    create or replace package body test_query is
    cnt number := 0;
    function get_next_count return number is
    begin
    cnt := cnt + 1;
    return cnt;
    end;
    end;
    select test_query.get_next_count from dual;
    This query, which should return 1, 2, 3, 4, etc actually returns 2, 4, 6, 8, etc, because SQL Developer is running the select twice.

  • Grant select sequence to other users

    Hi all,
    Assume: I have a user "A" who have table name "test" and sequence name "test_seq". How can the user "B" able to select on the sequence "test_seq" of user A, by this command below:
    connect B/password
    SELECT test_seq.nextval from dual;
    Thanks,

    A must run:
    GRANT SELECT ON test_seq TO b;B must run:
    CREATE SYNONYM test_seq FOR a.test_seq;Message was edited by:
    Pierre Forstmann

  • Sequence, nextval

    Hello,
    i'm writing an application, that has to have process unique index. I think of db-sequences for to create them. So i use jdbc and sql to retrieve the next value from the sequence.
    i do that by sequenceName.nextVal
    I wonder how to form the valid sql statement to retrieve the netx index of the sequence. Things like 'SELECT SQ_JOBNOS.nextval' caause oracle exceptions.
    do i have to create a temporary table?
    thanks a lot,
    best regards,
    nigoooh

    SELECT SQ_JOBNOS.nextval FROM dual

Maybe you are looking for

  • Im locked out of my iphone 4...HELP!

    My friend has given me an iPhone 4 but I am locked out of it and do not have the computer it is connected to, i've tried to connect it to my laptop but it wont work. Anyone know what to do please?

  • Filter condition in query designer

    Hi Friends, Can any one please tell me? Query is done on Multiprovider (made of Cube 1 to Cube 6 ) and in query designer under filter tab i have seen case 1: 1) Fiscal year variant F4 2) Cube 1 Questions: 1) what is the use of Fiscal year variant F4

  • Quicktime movie showing as 0:00 seconds

    I'm using Keynote 08, OS X 10.4.11, and Quicktime 7.5, and when I try to import .avi or .mov files, nothing works. The first frame is displayed, but nothing more. When I click on the media icon, it shows that the movies are 0:00 seconds long. I alrea

  • Problem in recovery

    hi, im using Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.4.0 - Production on oralinux 4. this server is standby database and it is in manual recovery mode

  • Compare and compute 2 dates

    I m getting 2 dates and timestamp from the oracle database, date1 from the Db schema table and date2 is the oracle sysdate. i presume at any given time date1 will be less than or equal to the date2. I want to compare the 2 dates and see the differenc