Sequence-next-val in xsl

I need to populate a db field with a value from a sequence I have in my database. When I drag the database function "sequence-next-val" into the middle swim lane and open it the "Add" and "Remove" buttons are ghosted. The labels for "sequence" and "datasource" seem to be ghosted as well. How do I get my sequence in this? I would assume that the "add" button would do what I need if I could get to it.
Thanks,
Mark

If someone else tries sequences in 10.1.2.0.2 here is how I finally got it to work.
Part of my issues are being new and part to BPEL. What I had to do was enter the sequence name in quotes (as expected). Enter the datasource as "jdbc:oracle:thin:mydb/mydbpwd@localhost:1521:ORCL" (again as expected) and then save, deploy and shut down and restart the development PM Server.
It looks like it must be shut down and restarted each time a new sequence is added for it to take effect. This makes it hard to know why the sequence doesn't work when it seems like it is all good. It was odd that the xsl test seemed to work but deployment didn't. But once you restart the PM server it goes. Hope this helps.
Mark

Similar Messages

  • Error while generating the seqence in soa 11g orcl:sequence-next-val

    Hi,
    In bpel we are using sequence-next-val, we are getting the below error. Anyone could you please let me know what might be the issue.
    Error :
    An error occurs while processing the XPath expression; the expression is orcl:sequence-next-val("XXSOA_MTR_BATCH_S","jdbc/XXSOADataSource").
    The XPath expression failed to execute; the reason was: internal xpath error.
    Check the detailed root cause described in the exception message text and verify that the XPath query is correct.
    <stack>
    <f>com.collaxa.cube.xml.xpath.BPELXPathUtil.evaluate#262</f>
    <f>com.collaxa.cube.engine.ext.bpel.common.BPELWMPHelper.evalFromValue#339</f>
    <f>com.collaxa.cube.engine.ext.bpel.v1.wmp.BPEL1AssignWMP.__executeStatements#137</f>
    <f>com.collaxa.cube.engine.ext.bpel.common.wmp.BaseBPELActivityWMP.perform#158</f>
    <f>com.collaxa.cube.engine.CubeEngine._performActivity#2463</f>
    <f>com.collaxa.cube.engine.CubeEngine.performActivity#2334</f>
    <f>com.collaxa.cube.engine.CubeEngine.handleWorkItem#1116</f>
    <f>com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal#73</f>
    <f>com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage#220</f>
    <f>com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory#328</f>
    <f>com.collaxa.cube.engine.CubeEngine.endRequest#4350</f>
    <f>com.collaxa.cube.engine.CubeEngine.endRequest#4282</f>
    <f>com.collaxa.cube.engine.CubeEngine.createAndInvoke#679</f>
    <f>com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke#654</f>
    <f>com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke#293</f>
    <f>sun.reflect.NativeMethodAccessorImpl.invoke0</f>
    <f>...</f>
    </stack>
    </exception>
    <root class="javax.xml.xpath.XPathExpressionException">internal xpath error<stack>
    <f>oracle.xml.xpath.JXPathExpression.evaluate#242</f>
    <f>com.collaxa.cube.xml.xpath.BPELXPathUtil.evaluate#240</f>
    <f>com.collaxa.cube.engine.ext.bpel.common.BPELWMPHelper.evalFromValue#339</f>
    <f>com.collaxa.cube.engine.ext.bpel.v1.wmp.BPEL1AssignWMP.__executeStatements#137</f>
    <f>com.collaxa.cube.engine.ext.bpel.common.wmp.BaseBPELActivityWMP.perform#158</f>
    <f>com.collaxa.cube.engine.CubeEngine._performActivity#2463</f>
    <f>com.collaxa.cube.engine.CubeEngine.performActivity#2334</f>
    <f>com.collaxa.cube.engine.CubeEngine.handleWorkItem#1115</f>
    <f>com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal#73</f>
    <f>com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage#220</f>
    <f>com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory#328</f>
    <f>com.collaxa.cube.engine.CubeEngine.endRequest#4350</f>
    <f>com.collaxa.cube.engine.CubeEngine.endRequest#4281</f>
    <f>com.collaxa.cube.engine.CubeEngine.createAndInvoke#679</f>
    <f>com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke#654</f>
    <f>com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke#293</f>
    -Thanks
    GVS

    Thanks for your reply. Well, I believe I know what the problem was. I used the JNDI name from the connection factory in the DB adapter eis/DB/my_ds. It did not like that. However, when I used the datasource's JNDI location jdbc/my_ds, it worked like a charm.

  • Use of 'sequence-next-val' in JDEV

    All,
    As part of my ESB project, I'm integration an appln. with Oracle EBS. My requirement is to populate a field with a sequence value. I found there is a db function in Jdev. As per the note, I used the 'sequence-next-val' function to generate sequence. In the function parameter 'sequence' I added the sequence as given in the note (orcl:sequence-next-val('<actualsequencename>,'jdbc:oracle:thin:<user>/<pwd>@<localhost>:1521:<SID>'). When I try to save the proejct, I got the following error
    ' (2):sequence-next-val: Error: Function with Too Few Parameters'. I'm clueless what could be the issue?
    Any help on this is highly appreciated.
    Regards,
    sen

    Hi sen,
    The function orcl:sequence-next-val takes 2 parameters. It return the next value of an Oracle sequence. It is similar to sequence generation what we see in Oracle sql.
    How to proceed:
    First of all you need to drap that function to the tranformation swimlane. Create a database sequence, say,TEST. This will be the first parameter for the function.
    The second parameter will be your database connection details, i.e. the database in which your source table is defined.
    Suppose your database is having details as:
    Username: abhi
    Password: abhishek
    Host: 172.128.5.13
    Port: 1521
    SID: Oracle
    so the second parameter will look like this:
    'jdbc:oracle:thin:abhi/[email protected]:
    1521:Oracle'
    or for the second parameter you can add a datasource entry in data-sources.xml file under soa_home\j2ee\oc4j_soa\config.
    Say the datasource name is BPEL_DBS. so the function will look like,
    orcl:sequence-next-val('TEST','jdbc/BPEL_DBS')
    After doing this, map it to the destination field.
    Cheers,
    Abhi...

  • Orcl:sequence-next-val

    Hi
    I saw many discussions in the functions, but couldnt get an answer. I wanted to know if passing the JNDI connection identifier as second parameter works or not. I tried passing the same but got time out exceptions (which means it didnt work)
    If this works can some one please show me the connection identifier in the xml file oc4j-ra.xml , and also the right syntax to call it , or are there any examples provided for this.
    If this doesnt work what is the way to do this , i mean get the next sequence value. I cannot use the jdbc url as it is a production instance.
    Really appreciate your help on this.
    Thanks
    -Pradip

    Hey,
    You might be having problem with the datasource. One to check this is :
    1. Go TO Enterprise Manager
    2. Go To DataSources
    3. Click Test Connection for your Datasource
    4. Type your sql: select schemaname.SequeceName.nextval from dual
    5. Click test.
    6. If you get confirmation message "Connection to "DataSource" established successfully"
    that means your datasource is working fine and you have coding issue.
    7. If it you dont get above message then check the datasource configuration.
    Let me know if it help.
    Regards,
    Yogesh

  • Problem with the browse sequence back and browse sequence next widget placed in the screen layout

    Hi,
    Some basics: We are using Robohelp 10 to  generate multiscreen  html5 output. We used the pharmaceutical  screen layout downloaded from:  http://helpx.adobe.com/robohelp/robohelp-screen-profiles-layouts.html but modified it to match our GUI.
    We are having a problem with the browse sequence back and browse sequence next buttons placed in the screen layout from the widgets tool bar. We are in no way experts at this part of Robohelp...and the css portion of all this is a bit of mystery but we have managed to get mostly what we need. Now we just need these buttons to work. In the past we used Airhelp and things worked great. Can anyone help us understand why the sequence buttons are not showing up in the output even though it does in the topic preview?
    Also
    This shows up in the  layout.css file:
    a.wBSBackButton {
                    margin: 0 8pt 0 0;
                    padding: 0;
                    background-color: transparent;
    img.wBSBackButton {
                    border: none;
    a.wBSNextButton {
                    margin: 0 8pt 0 0;
                    padding: 0;
                    background-color: transparent;
    img.wBSNextButton {
                    border: none;
    Also btw, I forgot to mention that we are linking our FrameMaker files.
    Appreciate the help.
    Thanks!

    hi pradeep
    It does not happen but if you Wait for a while that may be solved

  • Best way to get sequence.next value in pl-sql/triggers

    Hi,
    I want to know the best practice about to get the sequence.next value in pl-sql procedures / triggers from the below two methods.
    1. SELECT PRINT_BATCH_SEQ.NextVal INTO PSQNO FROM DUAL;
    INSERT INTO TABLE R1TMP VALUES (PSQNO, '12-MAR-06');
    2. INSERT INTO TABLE R1TMP VALUES (PRINT_BATCH_SEQ.NextVal, '12-MAR-06');
    From the above two statements which one is best with respect to performance / parsing /memory usage.
    Kindly give your suggession please.
    Thanks,
    Riaz.

    Hi,
    Thanks for your immediate reply.
    My thought was
    1. when we do like this, at the time of insert the cost of the operation will be more and this will lead some performance issue as bulk insert.
    2. If we get it from dual and send the value as bind variable, then we can avoid the parsing of the sql.
    Please correct me if i am wrong.
    thanks,
    riaz.

  • How to alter sequence next number

    Can we alter sequence next number. I want to start it from minval.

    To restart the sequence at a different number, you must drop and re-create it.
    If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value.
    Oracle Database performs some validations. For example, a new MAXVALUE cannot be imposed that is less than the current sequence number.

  • Sequence next value into a VIEW

    Hi all,
    I am getting this error when i try to include sequence value in aview....
    please suggest where i am doing wrong or if there is any work around...
    CODE
    CREATE OR REPLACE FORCE VIEW XREF_DATA_PRODUCT_V_2
    XREF_COLUMN_NAME,
    VALUE,
    ROWID_1
    AS
    SELECT 'SEBL_01', A.sebl_01, ROWID
    FROM XREF_GOMS_STG A
    UNION
    SELECT CASE
    WHEN C.SOMS_01 = 'Engine Parts' THEN 'GOMS_01'
    ELSE 'SOMS_01'
    END,
    c.goms_01,
    ROWID
    FROM XREF_GOMS_STG C
    union
    select 'COMMON',odipocsrc.xref_data_sequence.nextval,rowid
    from ODIPOCSRC.XREF_GOMS_STG B
    ORDER BY 3;
    Thanks

    Hi,
    Why do you want to use a sequnce there? What are you trying to do? Would numbers generated by the analytic ROW_NUMBER function serve your purpose?
    Assuming you really need a sequence, you can hide the sequence in a user-defined function, and use the function in the view, like this:
    CREATE OR REPLACE FUNCTION     seq_x_nextval
    RETURN     PLS_INTEGER
    IS
         return_val      PLS_INTEGER;
    BEGIN
         SELECT     seq_x.NEXTVAL
         INTO     return_val
         FROM     dual;
         RETURN     return_val;
    END     seq_x_nextval;
    CREATE OR REPLACE VIEW     view_x
    AS
    SELECT     danme
    ,     seq_x_nextval     AS seq_val
    FROM     scott.dept;
    SELECT     *
    FROM     view_x;Output, when running the query above:
    DNAME             SEQ_VAL
    ACCOUNTING             52
    RESEARCH               53
    SALES                  54
    OPERATIONS             55Then, running the same query again:
    DNAME             SEQ_VAL
    ACCOUNTING             56
    RESEARCH               57
    SALES                  58
    OPERATIONS             59Edited by: Frank Kulash on Feb 15, 2010 7:42 PM

  • JPA: Oracle Sequence Generator not up to date

    Hi,
    I'm using the JPA Oracle Sequence Generator in one of my JPA classes:
    @Entity
    @Table(name = "DACC_COST_TYPE")
    public class JPACostType implements Serializable {
    @SequenceGenerator(name = "CostTypeGenerator", sequenceName = "DACC_COST_TYPE_SEQ")
        @Column(name = "ID_COST_TYPE")
        @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CostTypeGenerator")
        private Integer idCostType;
    In order to persist a new object I perform the following code:
    @PersistenceContext
    private EntityManager em;
    JPACostType myJPA = new JPACostType();
    myJPA.setIdCostType = null;
    em.merge(myJPA);
    em.flush();
    Normally this works fine. But after deploying the app there sometimes happens an error:
    Caused by: javax.persistence.PersistenceException: SQLException while inserting entity {com.karmann.dacc.ejb.busilog.jpa.JPACostType(idCostType=4)}.
    at com.sap.engine.services.orpersistence.core.PersistenceContextImpl.flush(PersistenceContextImpl.java:278)
    at com.sap.engine.services.orpersistence.core.PersistenceContextImpl.beforeCompletion(PersistenceContextImpl.java:565)
    at com.sap.engine.services.orpersistence.entitymanager.EntityManagerImpl.beforeCompletion(EntityManagerImpl.java:410)
    at com.sap.engine.services.orpersistence.environment.AppJTAEnvironmentManager.beforeCompletion(AppJTAEnvironmentManager.java:197)
    at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:232)
    ... 52 more
    Caused by: java.sql.SQLException: ORA-00001: unique constraint (AEMA.DACC_COST_TYPE_PK) violated
    Obviously JPA does not fetch the new key by accessing the Oracle sequence. This documents "next value = 5". Does JPA fetch the new key from its cache? Is there any possibility to avoid this?
    Thanks for each hint,
    Christoph

    Hello Christoph Schäfer  ,
    I am stuck with a similar issue. I was able to save mutiple entries and there has not been much change to my JPA. I added new entities and new sequences.
    Now, I get the error Caused by: javax.persistence.PersistenceException: java.sql.SQLException: ORA-02289: Sequence ist nicht vorhanden.
    I have checked the name of sequence and sequence next val on the DB. It works on DB but when i execute it from ejb, it gives me thsi error. Now, it gives the error for all previously working JPA entities.
    I have also provided allocationSize = 1 for all entities.
    Please let me know, possible cause/solution to this issue.
    thank you.
    Regards,
    Sharath

  • How to generat sequence number for db in XSLT

    Hello SOA Gurus,
    I have a requirement, Please see below
    I am using SOA 11.1.1.6
    From a webservice call to db insert XSLT,  i have 10 elements at source side and 11 elements at target side.
    From source to target first 10 mappings are done.
    Now requirement is, for the 11th element in target- we need pass a sequence number to the targeted database, means---(sequence number has to be generated for every execution of XSLT execution)
    How to do the last point???
    Can anyone help me plzz

    Hi,
    You can pass the sequence number in the 11th element using "oraext:sequence-next-val("Sequence name as a string", "Datasource as a string") function.
    Regards,
    Anshul

  • Service Bus 12c Class not found 'oracle.tip.pc.services.functions.ExtFunc'

    Hi,
    Did anyone came across this issue with Class not being found for XSLT Function used in transformer on 12c OSB.
    I'm using oraext:sequence-next-val and have configured as below:
    namespace-uri:http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc
    namespace-prefix: oraext
    Not sure why at runtime I'm getting below error, as the same was working fine in 11g OSB Domain.
    XML-22045: (Error) Extension function error: Class not found 'oracle.tip.pc.services.functions.ExtFunc'

    Have you restarted servers after putting jar in $Domain_Home/lib directory? Also try after explicitly adding this jar in classpath by editing server startup script (startManagedWeblogic.cmd or .sh) or in domain env setting script (setDonainEnv.cmd or .sh) and restarting the servers.
    Regards,
    Anuj
    Edited by: Anuj Dwivedi on Mar 21, 2011 1:10 PM

  • Issue with XSLT For each loop in B2B Mapping

    Hi All,
    I am trying to map the inbound 997 Payload into Headers and Lines Table. I am using the For Each XSLT Construct to map the Loop AK2 of 997 into the 997 Lines Collection.
    Issue I am facing is that if the Loop AK2 is repeated for 33 times then for all the 33 times only its first element's value is getting passed into the target of mapping file.
    in coming payload
    <Loop-AK2>
    <Segment-AK2>
    <Element-143>810</Element-143>
    <Element-329>0001</Element-329>
    </Segment-AK2>
    <Segment-AK5>
    <Element-717>A</Element-717>
    </Segment-AK5>
    </Loop-AK2>
    <Loop-AK2>
    <Segment-AK2>
    <Element-143>810</Element-143>
    <Element-329>0002</Element-329>
    </Segment-AK2>
    <Segment-AK5>
    <Element-717>A</Element-717>
    </Segment-AK5>
    </Loop-AK2>
    <Loop-AK2>
    <Segment-AK2>
    <Element-143>810</Element-143>
    <Element-329>0003</Element-329>
    </Segment-AK2>
    <Segment-AK5>After transformation using XSLT file the payload looks like as follows
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>33</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>34</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>35</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>36</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>37</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>the Element-329 of incoming source payload is mapped to trxSetControlNumber of target payload, the issue is obvious from the above XML data that trxSetControlNumber is always having the value 0001 for every occurence where as its expected to fetch the value of the element of its corresponding occurence not the first elements value.
    Please find below the xslt file code i used for mapping
    <ns0:XxmfiEdi997_AckHeadersCollection>
          <ns0:XxmfiEdi997_AckHeaders>
            <ns0:headerId>
              <xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_HEADERS_S","jdbc/MTSI-apps")'/>
            </ns0:headerId>
            <ns0:processFlag>
              <xsl:text disable-output-escaping="no">I</xsl:text>
            </ns0:processFlag>
             <ns0:xxmfiEdi997_AckLinesCollection>
              <xsl:for-each select="/ns1:Transaction-997/ns1:Loop-AK2">
                <ns0:XxmfiEdi997_AckLines>
                  <ns0:lineId>
                    <xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_LINES_S","jdbc/MTSI-apps")'/>
                  </ns0:lineId>
                  <ns0:trxSetIdentCode>
                    <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"/>
                  </ns0:trxSetIdentCode>
                  <ns0:trxSetControlNumber>
                    <xsl:value-of select="ns1:Segment-AK2/ns1:Element-329"/>
                  </ns0:trxSetControlNumber>
                  <ns0:segmentError>
                    <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Loop-AK3/ns1:Segment-AK3/ns1:Element-720"/>
                  </ns0:segmentError>
                  <ns0:trxSetAckCode>
                    <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK5/ns1:Element-717"/>
                  </ns0:trxSetAckCode>
                </ns0:XxmfiEdi997_AckLines>
              </xsl:for-each>
            </ns0:xxmfiEdi997_AckLinesCollection>
          </ns0:XxmfiEdi997_AckHeaders>Is there something I am doing wrong in mapping or am I missing something here. Please suggest .
    Thanks in advance
    ~TK.

    Hi,
    In your xslt code within the for loop, for the trxSetIdentCode why are you using the xpath "/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"? It should be just "ns1:Segment-AK2/ns1:Element-143". Similar changes for segmentError and trxSetAckCode also should be done. Remove the '/ns1:Transaction-997/ns1:Loop-AK2/' part from your xpath expressions inside the for loop and try it.
    Sahay

  • How to get Database functions into xquery/XSLT in OSB 12c

    Hello All,
    How to make use of  functions orcl:sequence-next-val and orcl:query-database in xslt/xquery in OSB 12c.
    I need to do the below logic in xslt/xquery and used it in replace activity . But in OSB 12c I don't see these function. Request to provide me the solution to do it in OSB.
    XSLT in SOA
    <xsl:when test="/ns0:CreateEvent/ns0:Header/header:SourceName != &quot;&quot;">
                <ns1:googleEventSourceId>
                  <xsl:value-of select="orcl:query-database(concat(&quot;select google_event_source_id from enterprise.google_event_source where google_event_source=&quot;,&quot;'&quot;,/ns0:CreateEvent/ns0:Header/header:SourceName,&quot;'&quot;),false(),false(),&quot;jdbc/PRDatasource&quot;)"/>
                </ns1:googleEventSourceId>
              </xsl:when>
    <ns1:googleMapEventId>
              <xsl:value-of select="orcl:sequence-next-val(&quot;enterprise.google_map_event_seq&quot;,&quot;jdbc/PRDatasource&quot;)"/>
            </ns1:googleMapEventId>
    please see below code is just part of my transformation.
    Regards,
    TJ.

    bump

  • 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>

  • 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.

Maybe you are looking for

  • "Computer no longer Authorized with this iPhone"

    Even though i have never synced with another computer & have used the same computer since I've had my iphone, during sync I have recently began getting the message that my computer is no longer authorized to my phone. I will not transfer apps and has

  • Detect something just copied to the clipboard

    Hi everyone, I'm wondering if it is possible for a java program to detect something just got copied into the system's clipboard? I don't mind using JNI if that helps. I need to be notified after a user "right click and select copy" in any application

  • How can I interrupt the blocking call when call timeout?

    Hi,Guys I wrote an application server(daemon process) to talk with oracle server continuous which used oracle9 OCCI lib, each 5 min it executes the procedure on the DB server. Now I have come cross a problem: If the network is blocked, app server wil

  • UWL Configuration in Portal

    Hi Please let me know the steps of Configuration UWL in EP. Also, let me know how Users are assigned / removed  to access UWL. Regards

  • Between with decode

    can you please tell me how should i write this DECODE(G.EARLY_PREV, 'Y', E.sDATE BETWEEN last_run_date And run_date, E.sDATE BETWEEN (last_run_date + 1) And run_date) Thanks