Multiple destination tables, oracle sequence problems

Hello,
Please look at this sql - there is 2 steps to add data to 2 destination tables:
- step1:
INSERT INTO OBIEKTY (ID_OB, TELEFON, FAX, NR_LOKALU, UWAGI, ULICA, GEOM, NR_BUDYNKU, KOD_POCZTOWY, LISTA_OBIEKTOW, EMAIL, GMINA, NAZWA, WOJEWODZTWO, MIEJSCOWOSC, USUNIETY, POWIAT, JEDNOSTKA_WYJAZDOWA, MIEJSCOWOSC_POCZTY)
VALUES (OB_SEQ.NEXTVAL, null, null, null, null, 'Legionowa', null, '8', '15-099', '0', null, null, 'WSSE w Białymstoku',null , 'Białystok', null, null, '0', null);
-step2:
INSERT INTO ZASOBY (ID_ZAS, UZYT_TWORZACY, UWAGI, UZYT_OST_MODYFIKACJI, DATA_OST_MODYFIKACJI, DYSPONOWALNY, DATA_UTWORZENIA, USUNIETY, ID_SPRZETU, ID_PAT, ID_MAT, ID_INST, ID_KATEGORII, ID_OBIEKT, ID_POZ_SL, ID_OSOBA, IMPORT)
VALUES (ZAS_SEQ.NEXTVAL, 'import', null, null, null, '0', SYSDATE, '0', null, null, null, null, KTZ_SEQ.CURRVAL, OB_SEQ.CURRVAL, (select p.id_poz_sl from pozycje_slownikow p join slowniki s on p.id_slownika=s.id_sl where s.nazwa like 'TYPY_ZASOBOW' and p.kod = 'OB'), null, '1');
There are problems with sequences. As you can see, there is OB_SEQ.NEXTVAL in first step and OB_SEQ.CURRVAL in second step. It's impossible to define multiple destination tables in one interface. But, if I do this in multiple interfaces, OB_SEQ.CURRVAL will be undefined in second interface.
Also, all steps should be performed row by row. So: first step for first row, second step for first row, first step for second row, second step for second row etc. This don't happen if I use multiple interfaces - first step will be performed for all source records and then, second step will be performed for the same records - this is not what I want.
Do you have any tips what is the best way in this case?

Hello,
Unfortunately, problem is not solved still. As you can see, there are 2 sequences, from 2 not joined tables: KTZ_SEQ.CURRVAL, OB_SEQ.CURRVAL. KTZ_SEQ.CURRVAL is declared here:
insert into KATEGORIE_ZASOBU (ID_KTZ, UZYT_TWORZACY, UZYT_OST_MODYFIKACJI, LOKALIZACJA, DZIEDZICZENIE, DATA_OST_MODYFIKACJI, DATA_UTWORZENIA, DYSPONOWALNA, SYSTEMOWA, WYBIERALNA, OPIS, NAZWA, USUNIETA, ID_KATEGORII1, ID_POZ_SL, IMPORT)
values (KTZ_SEQ.NEXTVAL, 'import', null, '0', '0', null, SYSDATE, '0', '0', '1', null, 'Jednostki WSSE', '0', null, (select p.id_poz_sl from pozycje_slownikow p join slowniki s on p.id_slownika=s.id_sl where s.nazwa like 'TYPY_ZASOBOW' and p.kod = 'OB'), '1');
So, summary:
- there are 2 steps (OB_SEQ.CURRVAL. KTZ_SEQ.CURRVAL) are set
- third step: insert some hardcoded data + OB_SEQ.CURRVAL. KTZ_SEQ.CURRVAL values.
Since KATEGORIE_ZASOBU and OBIEKTY are not joined, I can't add them as datasources in my interfaces (how to create join?) and set CURVAL?

Similar Messages

  • OC4J -Time out and Oracle sequence problem

    hi
    i m using OC4J to access application which is using java as front and
    and we using oracle sequence with cache as 20.
    so when i accessing application thro' network my sequence skip from 20
    mean 1-21-41-61 is it possible due to if lost connection opened from java for oracle thro' OC4J ? will it keep cache ?or lost ? is it really time out error?
    if then hw to set time out in oracle?
    u can refer below link
    Re: ORABPEL-05002

    i think i may be having the same problem. My table is savings entries out of order. I would assume that each row saved would be in sequence number order...instead it goes from like 963, 964, 678, 679, ....??? wonder why it would place new entries in front of older entries in the table???

  • Oracle sequence problem in CMP Entity EJB

    I have a problem with Oracle sequence when I am using from the CMP entity EJB in WebLogic
    6.1:
    The problem is when the WebLogic server starts it acquires the correct sequence number
    from Oracle, but during the runtime, when I open a new sqlplus window and increment
    the sequence number, the container is not picking up from the new incremented value
    instead it is still continuining by incrementing the old sequence number it has acquired
    when it fetched from Oracle last time.
    The sequence increment and key-cache-size in weblogic-cmp-rdbms-jar.xml are exactly
    same
    Any help would be greatly appreciated.

    Change the key-cache-size to 1 in weblogic-cmp-rdbms-jar.xml and then try
    your experiment again.
    -- Anand
    "Satya" <[email protected]> wrote in message
    news:3d06274c$[email protected]..
    >
    I have a problem with Oracle sequence when I am using from the CMP entityEJB in WebLogic
    6.1:
    The problem is when the WebLogic server starts it acquires the correctsequence number
    from Oracle, but during the runtime, when I open a new sqlplus window andincrement
    the sequence number, the container is not picking up from the newincremented value
    instead it is still continuining by incrementing the old sequence numberit has acquired
    when it fetched from Oracle last time.
    The sequence increment and key-cache-size in weblogic-cmp-rdbms-jar.xmlare exactly
    same
    Any help would be greatly appreciated.

  • Inserting data into multiple tables(Oracle Version 9.2.0.6)

    Hi,
    we are going to receive the following XML file from one of our vendor. We need to parse the file and then save the data to multiple database tables (around 3).
    <?xml version="1.0"?>
    <datafeed xmlns:xsi="ht tp://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DailyFeed.xsd" deliverydate="2007-02-14T00:00:00" vendorid="4">
    <items count="1">
    <item feed_id="001379" mode="MERGE">
    <content empbased="true">
    <emp>10000000</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="EN">
    <url>www.pqr.com</url>
    <description>pqr website</description>
    </link>
    <link lang="DE">
    <url>www.efg.com</url>
    <description>efg website</description>
    </link>
    </links>
    </content>
    <content empbased="true">
    <emp>10000001</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="EN">
    <url>www.abc.com</url>
    <description>abc website</description>
    </link>
    <link lang="DE">
    <url>www.xyz.com</url>
    <description>xyz website</description>
    </link>
    </links>
    </content>
    <content empbased="true">
    <emp>10000002</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="IT">
    <url>www.rst.com</url>
    <description>rst website</description>
    </link>
    </links>
    </content>
    </item>
    </items>
    </datafeed>
    Now the operation to be done on the table depends on the mode attribute. Further, there are some basic validations need to be done using count attribute. Here the item tag, content tag & link tag are recurring elements.
    The problem is I am not able to find the correct attributes like mode, feed_id, lang through SQL query(they are getting duplicated) though I was able to find the deliverydate & vendorid attribute as they are non-repeatitive. Here are the scripts :
    create table tbl_xml_rawdata (xml_content xmltype);
    create directory xmldir as 'c:\xml';
    --put the above xml file in this directory and name it testfile.xml
    Declare
    l_bfile BFILE;
    l_clob CLOB;
    BEGIN
    l_bfile := BFileName('XMLDIR', 'testfile.xml');
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
    dbms_lob.loadFromFile(dest_lob => l_clob,
    src_lob => l_bfile,
    amount => dbms_lob.getLength(l_bfile));
    dbms_lob.close(l_bfile);
    insert into test_xml_rawdata values(xmltype.createxml(l_clob));
    commit;
    end;
    My query is:
    select extractvalue(value(b),'/datafeed/@deliverydate') ddate, extractvalue(value(b),'/datafeed/@vendorid') vendorid,
    extractvalue( value( c ), '//@feed_id') feed_id,
    extractvalue( value( a ), '//@empbased') empbased,
    extractvalue( value( a ), '//emp') emp,
    extractvalue( value( a ), '//value') value,
    extractvalue( value( a ), '//unit') unit,
    extractvalue( value( a ), '//date') ddate1,
    extract( value( a ), '//links/link/url') url,
    extract( value( a ), '//links/link/description') description
    from tbl_xml_rawdata t,
    table(xmlsequence(extract(t.xml_content,'/datafeed/items/item/content'))) a,
    table(xmlsequence(extract(t.xml_content,'/'))) b ,
    table(xmlsequence(extract(t.xml_content,'/datafeed/items/item'))) c;
    If the above query is run, the feed_id is cartesian joined with other data ,which is wrong.
    How should I go with this so that I can have 1 relational record with respect to each element & sub-elements.
    Also, if this is not doable in SQL, can someone direct me to some plsql example to do this. I read that dbms_xmldom & dbms_xmlparser can be used to travel through XML doc but I don't know how to use them.
    Any help please ??

    I'm still getting the same error while installing Oracle Patch set 9.2.0.6. I downloaded the patchset 2 weeks back.
    Pls help where download the correct version ?

  • Insert multiple records into a table(Oracle 9i) from a single PHP statement

    How can I insert multiple records into a table(Oracle 9i) from a single PHP statement?
    From what all I've found, the statement below would work if I were using MySQL:
         insert into scen
         (indx,share,expire,pitch,curve,surface,call)
         values
         (81202, 28, 171, .27, 0, 0, 'C' ),
         (81204, 28, 501, .25, 0, 0, 'C' ),
         (81203, 17, 35, .222, 0, 0, 'C' ),
         (81202, 28, 171, .27, 2, 0, 'C' ),
         (81204, 28, 501, .20, 0, 1, 'C' ),
         (81203, 28, 135, .22, 1, 0, 'C' )
    The amount of records varies into the multiple-dozens. My aim is to utilize the power of Oracle while avoiding the i/o of dozens of single-record inserts.
    Thank you,
    Will

    You could look at the INSERT ALL statement found in the documentation here:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
    My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
    The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
    HTH.

  • Sql Problems, Same Field Names In Multiple Mysql Tables?

    I have a keyword search that searches multiple DB tables for thumbnail images using UNION ALL. I have two pages, results.php, and view.php.  My goal is to able to click a thumbnail image on results.php and be directed to a larger version of that same image on view.php. The problem is each image in all my tables uses the field name "id" so when I click a thumbnail on results.php I get two different images with the same id from different tables.  I tried changing the id's to different names, but when it was time to pass url parameters I can only choose 1 value. (if you can choose more than 1 I don't know how).  So my question is why are my id's from different tables being grouped together, and how can I change this?
    Image Results Page (which works perfect):
    SELECT *
    FROM table1
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    UNION ALL
    SELECT *
    FROM table2
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    View Image Page (having problems here):
    SELECT *
    FROM table1
    WHERE id = colname
    UNION ALL
    FROM table2
    WHERE id = colname

    Yes, that is going to be a problem - and it's just the beginning of your problems when you do not normalize your data. Your data model is not correct. You should not be storing similar data in 15 tables - it's a really big mistake.
    To solve your current problem you would need to include a table identifier in the query results in the Image results page, and pass that to the view page and then use PHP to dynamically create the SQL with the correct table....ugh!

  • Problem in creating reports with one multiple detail tables

    hi,
    i tried to create workbook in the discoverer user edition with ONE MASTER TABLES AND MULTIPLE DETAL TABLES. but it does not allow . is there any solution ?
    NAresh

    I've given up on trying to do this in the user edition - the 2 masters to multiple details. Instead, I create custom folders in the admin edition. They never complain about masters and details. If anyone ever figures out how to do this in the User Edition, I'd sure like to hear about it. I do agree that the original problem - 1 master to multiple details works fine in 3.1.44.

  • JDBC Adapter - Multiple Table Update - Sequence Number

    I have to design a integration scenario where I will be updating 4 tables in a oracle database. One of these tables is a header table and the rest are detail tables. I have to generate a sequence number using Oracle Sequence number object which is one of the columns in the header table.
    How can i use the Oracle SEquence number object to get the next value with JDBC Adapter?

    Use an Enhancement Spot

  • Importing multiple csv's (different structures) to destination table

    I am using a data flow task with flat file source and ole db destination and looping thru a folder to import multiple csv files into a destination table. What if I wanted to import different csv files, for example, with different structures or layout.
    The different csv's would have the same columns for destination table  but in different order/name. How do u map each one to the destination table? Multiple data flow tasks or multi flat file sources?

    The standard Data Flow Task supports only static columns metadata defined at design time. I would recommend you check the commercial COZYROC
    Data Flow Task Plus. It is an extension of the standard Data Flow Task, which supports dynamic columns metadata. You can handle all your input flat files using single
    Data Flow Task Plus.  No programming skills are required.
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

  • Importing data from Microsoft excel file to Oracle Database with Multiple Data Tables. Need expert advice and guidance

    I posted a query on Importing data from Microsoft Excel to Oracle Database (Multiple Data Tables). I got some answer and reference from the forum.
    I presented to my Oracle consultant and representative from Oracle Malaysia. They said impossible. I do not believe what they said. I do believe can be done.
    Can someone help or direct me to an expert that can help me on this

    e90f478a-c529-4c48-b189-51eebeaed477 wrote:
    I posted a query on Importing data from Microsoft Excel to Oracle Database (Multiple Data Tables). I got some answer and reference from the forum.
    I presented to my Oracle consultant and representative from Oracle Malaysia. They said impossible. I do not believe what they said. I do believe can be done.
    Can someone help or direct me to an expert that can help me on this
    We don't know the "query on Importing data from Microsoft Excel to Oracle Database (Multiple Data Tables). "
    We don't know where you posted said query.
    We don't know what "some answer and reference" you received "from the forum."
    We don't know what it was that your "Oracle consultant and representative from Oracle Malaysia" said was "impossible".
    So on what basis are we supposed to "help or direct" to "to an expert that can help "?

  • Mixing sun-database-binding with Oracle sequences

    Hello,
    I wish to insert rows inside the database, for instance rows representing persons, and rows representing their addresses. Primary keys for both person and address are Oracle sequence based.
    My question is, if I insert a person, then one of her address, how can I retrieve the person ID for the address row to reference it.
    The insert statement for the person is (for the moment) as follow
    insert into Person (PERSON_ID, FIRST_NAME, LAST_NAME) values (PERSON_SEQ.nextval, ?, ?)The problem with this approach is that I never know the person ID, and am unable to make any references to it in the address row.
    I tried to add an operation in the NetBeans generated person table WSDL. This operation would execute this statement:
    select PERSON_SEQ.nextval from dualBut, for the moment, it's a failure.
    Could you provide me with some hints?

    Hi,
    First I would advise you to register and post on the [email protected] alias - you can find the details of how to do this on the OpenESB site..... you'll reach a larger audience this way.
    Second, you need a Stored Procedure in Oracle to do this, then use this from the DB BC, here's one I created which does something similar, i.e. returns a value I'm interested in after an "Update" statement....
    CREATE OR REPLACE PROCEDURE "NEXTAPPNUMFINDER" (nextAppNum OUT NUMBER)
    IS
    BEGIN
    UPDATE ACTIVE_APPLICATION_NUMBER
    SET APPLICATION_NUMBER_NEXT = APPLICATION_NUMBER_NEXT + 1
    RETURNING APPLICATION_NUMBER_NEXT
    INTO nextAppNum;
    END;
    Hope this helps
    Mark

  • Insert data into oracle based on sql server data(here sql server acting as source to oracle and destination to oracle)

    Source is Oralce. Destination is SQL Server.
    Requirement - I have to fetch sql server server data (empid's) based emp table  and send this as input data to oracle to fetch and empid's are common.
    I cannot use merge or loopkup or for each as oracle have too many records.
    For example - In MS SQL - i have empid=1,2..Only these records, I have to fetch from oracle source into sql server destination. For this, I have adopted the below approaches...The major problem I face, when i build a empid's as a string, it is taking only
    4000 chars. My string lenght is 10000. How do I breakup this string lengh and send to data flow task till all broken strings length passed to DFT.
    Approach-1
    created two variables - oraquery string, empid string
    step1 - ms sql database - created sql task - declare @empid varchar(max)
    SELECT @empid=
    Stuff((SELECT ',' + empid
            FROM  
            (SELECT  DISTINCT  convert(varchar(10),empid ) empid FROM emp
             ) x
            For XML PATH ('')),1,1,'')
    select @empid =    '(' +  @empid + ')'
    select @empid
    resultset=singlerow
    resultset=resultname=0; variablename=User::empid (empid is declared as string)
    step2 - oracle database - created data flow task
    created oledb source
    I put  this statemnt in oraquery expression - "select * from dept where dept in  "
    +  @[User::empid] + "
    expression=true
    [OLE DB Source [1]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E14.
    An OLE DB record is available.  Source: "Microsoft OLE DB Provider for Oracle"  Hresult: 0x80040E14  Description: "ORA-00936: missing expression".
    Approach-2
    created three variables - oraquery string, empid  int, loop object--when I put int then it is automatically setting to 0
    step1 - ms sql database - created sql task - SELECT  DISTINCT  convert(varchar(10),empid ) empid FROM emp
    resultset=fullresult
    resultset=resultname=0; variablename=User::loop
    step2 - created a for each loop container
    for loop editor - for each ado ennumerator
    enumerator configuration - loop
    variablemapping - variable=empid;index=0
    step3 - oracle database - created data flow task (outside for each loop. If I put inside it is taking long time)
    created oledb source
    I put  this statemnt in oraquery expression - "select * from dept where dept in  "
    +  @[User::empid] + "
    expression=true
    Data inserting in a destination table but  empid=0.

    Sorry didnt understand if your step3 is outside loop how
    @[User::empid] will get values for the empids from User::loop. The iteration happens inside loop so you
    need to have a logic to form the delimited list inside using a script task or something and concatenating everything and storing to variable @[User::empid]
    . Then only it will have full value used to be used in step3 query
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Oracle insert problem(records not in the order they are inserted)

    hi, all:
    I tried to insert a word list into a oracle table, everything is fine except that the words are not in the order they are inserted. For example, the words are inserted in the following sequence:
    accreted     
    accreting     
    accretion     
    accretionary     
    accretive     
    bladebone
    bladed     
    bladeless
    bladelike
    When I retrived the resultset from the table and iterate through each of the record, the words are not in the order inserted, i.e., it may look like this,
    accreted     
    accreting     
    bladebone
    bladed     
    accretion     
    accretionary     
    accretive     
    bladeless
    bladelike
    This strange phenomenon won't happen when the word list is small, like 500 words or so, but when the number of words reaches around 10,000, it takes place. My coworker also experienced this problem when trying to insert large volume of data into oracle table.
    The code I used to insert into the DB table:
    BufferedReader reader=new BufferedReader(new FileReader("C:\\Dictionary.txt"));
    while( (line=reader.readLine())!=null )
         sql="INSERT INTO DICT " +
         "VALUES ('" + line +"')";                         
         statement.executeUpdate(sql);
    Any advice will be highly appreciated,
    thanks

    Well, the best thing to do is follows scsi-boy's advice and add the additional column and either put a sequence number in it from the Java side as you insert, or use an Oracle sequence object to put a sequence number in it from the Oracle side (which is sort of like an auto-generated value, but different).
    Note that an Oracle sequence generates numbers in sequence, but possibly with gaps (usually if the database is rebooted), unless you do some things that slow sequences down substantially. Sequences can also be something of a bottleneck on RAC clusters. See:
    http://www.dizwell.com/oracle/articles/autonumbering.html
    However, if your coworker is commiting after each and every insert (which is bad form and slows the database down, -10 points), and if your coworker is also never ever ever updating the columns after they've been inserted, and if your coworker is using Oracle 10g and not some older version such as 9i, then your coworker could use the ORA_ROWSCN pseudo-column to order by. Those are very very severe constraints and you shouldn't begin to consider doing it that way without a very good reason, and right now you and your coworker wouldn't know a good reason if it snuck up and bit you on the butt, you've got a lot of learning the basics first.

  • Bulk Fetch From an Oracle Sequence

    I am trying to get a range of sequence values from an Oracle sequence.
    I am using the option as show below using query
    SELECT SEQUENCE_NAME.NEXTVAL FROM SYS.DUAL CONNECT BY LEVEL <= 10.
    The above SQL gets 10 sequence value.
    I just wanted to to check, if the implementation below is safe in a Multi User Environment?
    Is the statement show below atomic. i.e. Multi parallel execution of the same function; Would it cause any inconsistencies?
    EXECUTE IMMEDIATE 'SELECT SEQUENCE_NAME.NEXTVAL ' ||
      'FROM SYS.DUAL CONNECT BY LEVEL <= ' || TO_CHAR(i_quantity)
      BULK COLLECT INTO v_seq_list;
    FUNCTION select_sequence_nextval_range(
       i_quantity      IN  INTEGER)
    RETURN INTEGER IS
      o_nextval INTEGER;
      v_seq_list sequence_list;
    BEGIN
      EXECUTE IMMEDIATE 'SELECT SEQUENCE_NAME.NEXTVAL ' ||
      'FROM SYS.DUAL CONNECT BY LEVEL <= ' || TO_CHAR(i_quantity)
      BULK COLLECT INTO v_seq_list;
      -- Get the first poid value.
      o_nextval := v_seq_list(1);
      RETURN o_nextval;
    END select_sequence_nextval_range

    Acquire Lock
    You acquire a lock on a sequence? That's news to me - please post the code that does that. I certainly hope you don' t mean you are directly accessing the SYS.SEQ$ table to lock the row for that sequence - it isn't nice to mess with Oracle's tables!
    For couple of JAVA/C applications the usage of sequence number is pretty big. Could be 100,000 for one single application processing.
    How does that correlate with your previous statement that you get 10 at a time?
    Sequences aren't designed for use cases that require gap-free sets of numbers or for use cases that require consecutive sets of numbers.
    We wanted to implement the range get of sequence using a different mechanism.
    For few other applications; we just need one sequence number for the application processing. So we use the select seq.nextval to get the value. So the same sequence number needs to serve the role of giving a single value as well as a consecutive range of values.
    Then you may need to consider using your own table to track the chunks that need to be allocated. You would use a scheme similar to what Greg.Spall discussed except you would keep the 'chunk' data in your own table.
    I'm not talking about using your own table to control actual one-by-one sequence number generation - that is a very bad idea. But if you need to work with large ranges that are allocated infrequently there is nothing wrong with using your own function and your own table to keep track of those allocations.
    The 'one by one' number generation would be handled by an actual sequence. The generation of a 'start value' and an 'end value' would be handled by accessing your custom table. Each row in that table would have 'start_value' and 'available_numbers' colulmns.
    Your function would take a parameter for how many numbers you need. For just one number the function would call the sequence.nextval and return that along with a count of '1'.
    For a range the function would:
    1. find a row in the table with an 'available_numbers' value large enough to satisfy the request,
    2. lock the row for update
    3. capture the 'start_value' for return to the user
    4. adjust both the 'start_value' and 'available_numbers' values to account for the range being allocated
    5. update the table and commit
    6. return the 'start_value' and 'number_allocated' to the user (number_allocated might be LESS than requested perhaps)
    The above is a viable solution ONLY if the frequency of allocation and the size of allocation avoids the serialization issues associated with trying to allocate your own sequence numbers.
    Those issues can be somewhat mitigated by having the table store multiple rows with each row having a large chunk of values that can be allocated. Then your function query can get the first 'unlocked' row and avoid serializing just because one row is currently locked.

  • Back numbers in Oracle sequences

    We are using a J2EE based tool that uses Oracle as backend. For several purposes the tool use the oracle sequences. As per general rule the every time the sequence is referred, it generates a next higher number and returns the same for any kind of storage purposes like primary key, etc. But in rare cases we have got a previous number of the sequence instead of a next higher value. We aren't sure if that previous number was ever used before or not. But the problem is how does the oracle sequence return a previous number? e.g. we have a sequence running as 220, 221, 222, etc. then suddenly instead of returning 223 the next time, it may give the number 214 (or basically any previous number).
    Does anybody know why does that happen? What could be the possible reasons and how it can be avoided? It creates confusion amongst users and does not seem just right to get a previous number. Any help is appreciated. Thanks.

    Connection pooling should have no effect on this issue since the Oracle sequences should be cached in Oracle and not in the pooled session.
    RAC as mentioned would since each instance would have its own sequence cache: instance A values 1 - 5, instance B values 6 - 10, instance C 11 - 15.
    Then depending on which instance the user session was connected to the ticket numbers would appear to be selected from an earlier point in the sequence.
    On a non-RAC instance you can see this apparent behavior where the application gets the sequence number on the first screen and passes the value to later screens but the number is not inserted into a database table until the final screen that creates the ticket. If it takes the user longer to create the ticket than other users who started later then the ticket number would appear earlier than the earlier created tickets.
    The solution to this "problem" for non-RAC or RAC is to insert a timestamp at the time of ticket creation (or start) and to process the tickets in timestamp rather than ticket number order. After all the ticket number is just an identifier and there is really no logical reason that tickets have to be processed in ticket number order.
    If it is a political issue then you could use a dual key system. Assign one key at creation time, transaction key, and then assign the ticket number via batch based on either the timestamp of when ticket entry started or was submitted. Now the ticket numbers represent whatever order you need. You can notify the users of the ticket number via email.
    HTH -- Mark D Powell --

Maybe you are looking for

  • Windows 7 Upgrade - iTunes no longer see's my remote Airport Expresses

    Before upgrading from Vista to Windows 7, I deinstalled iTunes. After upgrading, I reinstalled the latest iTunes from Apple. iTunes appeared to be working fine until I played the 1st song. It could not find/connect the 2 remote Airport Express units.

  • HELP needed to write a function returning 1 record from join tables

    Hi, I would like to have some help to write a function so It can return 1 result. I post my question in the APEX Express sextion but I think it's belong here. Mount Points and Home Directory Also, can I move a thread in another forum? thanks Roseline

  • Why can't I get it to work?

    I recently established a paid @mac.com account. I entered a user name and password & did the rest of the required things. A week or so later it occurred to me that I should add the address to my email section (Entourage). Once I had gone through the

  • EMac Screen Shakes

    Hey Guys, My eMac Screen shakes a little if yo look at a corner. It looks like a vibration. The speaker volume thing doesn't work, neither does resetting nvram or PRAM or even changing the resolution. What can i do? Oh, i know a lot about macs, but n

  • To get the CS12 data

    Hi Experts, Is there any function module  available to get the CS12 data based on ( material, plant, Bom application (sd01-sales and Distribution). Please let us know. it would be helpful for me. Thnx, Sam.