Commit per row

Hi guys,
Need your suggestions. The problem I'm having is with primary keys. I have two columns (ID and Version Number) in my target data store. ID is not a unique identifier, so we added a version number for uniqueness. For example, records in the target datastore could be like this:
ID | Version
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
In the ODI mapping, I pick up the max(version) and add + 1 to the new record to be inserted for a particular ID. However, there could be multiple rows per ID in the source. And since these records are not in the datastore not after the commit, all the records for that ID gets the same version number (from max), therefore those rows could not be inserted because the primary key constraint will be violated.
Can anyone suggest a good approach on how to handle this?
Thanks,
Jason

jaysen,
I am not sure why would you do that. I am quoting what I wanted to do:
----QUOTE--------------------
INSERT INTO I$_TGT_TABLE (ID, VERSION)
SELECT ID,
(SELECT MAX(A.version) + 1 FROM TGT_TABLE A WHERE A.id = C$_0TGT_TABLE.id)
FROM C$_0TGT_TABLE C$_0TGT_TABLE
-----QUOTE ENDS--------------
Please notice that I wanted to do max from C$ table, not I$ table. Put the expression there:
(SELECT NVL(MAX(A.version),0) + 1 FROM <%=odiRef.getTargetTable("RES_NAME")%> A WHERE A.id = <%=odiRef.getTable("L","COLL_NAME","D")%>.id)
Execute the mapping at source.
Now this would not solve the problem if there are multiple rows with same id in the source table (go back to my post and see Rathish's reply to my post for an excellent case scenario). If you find the method of KM modification suggested in my earlier post too complicated, then here is another way remove the problem. Break the entire interface into three interfaces. The target resultset of the first and second interfaces should be used as a source in the third interface.
The first interface should take the data out of the source table and "version" column in the target table (in this case a temporary data store or landing table, let us call it T1) must be mapped as
ROW_NUMBER() OVER (PARTITION BY id ORDER BY id)
Use LKM and IKM as provided with ODI.
In the second interface take table TGT_TABLE as source and populate a second temp data store T2. This temp table should have "id" and "version" columns. Put max value of "version" column for each "id" value in this temp data store.
Use LKM and IKM as provided with ODI.
The third interface should use T1 and T2 as source sets (use left outer join as a join method with id as the common joining column). Use TGT_TABLE as target and mapping for "version" column should be "T1.version + NVL(T2.version, 0)".
Use LKM and IKM as provided with ODI.
That should take care of it. I am sure a far more "elegant" or "least-maintenance" solution exists, but I do not see any simpler solution than this. If you try to accomplish this same task through plain SQL, it is difficult to do this without using two temporary tables or two CTES (or derived tables).
If I were you, I would be using the target temporary data store that ODI can build instead of creating and maintaining two pairs of temporary tables in the database. But that is a decision you should be making.

Similar Messages

  • I parallelize the use of SQL*Loader.But it always commit per 89 rows

    I parallelize the use of SQL*Loader. But it always commit per 89 rows. How can I set Commit Row Number?

    enlarge the BINDSIZE= and ROWS= option or better use DIRECT=TRUE
    (and no need to parallelize [whatever this is in your case])

  • Interactive Report - Icon View - Dynamic Columns per Rows ?

    Hi all,
    We use the icon view functionnality in Interactive Report.
    Is there a way to display the 'columns per row' attribute as an application item and set it dynamical via PL/SQL ?
    Any suggestions?
    Thanks in advance for advices,
    Regards,
    Grégory

    Hi,
    Apex 4.0 interactive reports and images (Scott's thread)
    Have some useful information and pointers to the solution you are looking for.
    I hope this help.
    Thank you,
    Ranish

  • SMARTFORM:  How to print on document per row in an internal table

    Hi.
    I have created a SmatForm that is a one-page document to be printed once for every row in an itab I'm sending it via the Table Interface.
    I hope I didn't waste my time designing this form but I created several Windows for each section (header, recipient address, summary of coverage, detail coverage information, disclaimer, etc.).  I arbitrarily chose the header window as the "main" window (mainly because I couldn't find out what the difference between  the different choices was).  I've got the form laid out exactly how I want it.
    If I test the SmartForm and pass in 2+ records via the test screen only the first one prints. 
    I thought about trying a LOOP but since you have to place the text within the loop that means all the Windows I have defined won't "get" any of the data.
    I thought about looping in the driver ABAP program and just calling the SmartForm once per row but that seems horribly inefficient.
    PLEASE HELP!  Can I salvage what I've done already?

    Valter:
    OK.  I'm trying this and running into a snag.
    In the Form Interface section I have a table interface parameter defined as this: 
    P_CERTIFICATES_IN TYPE ZBNTT_LIFECERTIFICATE
    next I declared a variable named "IT_CERTIFICATES LIKE LINE OF P_CERTIFICATES_IN" in the "Global Definitions" section and on my LOOP element (under my new MAIN window) I have "[X] Internal Table" checked and
    "P_CERTIFICATES_IN" "INTO" "IT_CERTIFICATES"
    but the compiler says "Global Definitions     Field "P_CERTIFICATES_IN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . .".
    Why can't the Smartform "see" P_CERTIFICATES_IN?

  • Want to fix four items per row in a gridview in Windows Phone 8.1 app. I am using data binding.

    No of items in a row of grid varies for different resolution WP devices. How can it be fix to say 4 items per row. Here is xaml:
    <DataTemplate x:Key="DataTemplate1">
    <Grid Margin="8,0">
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,9.5,0,0">
    <Image x:Name="image" Height="100" Width="100" Source="{Binding ImageName}" >
    </Image>
    </Border>
    <TextBlock Grid.Row="1" Text="{Binding Name}" />
    </Grid>
    </DataTemplate>
    <Grid>
    <GridView ItemTemplate="{StaticResource DataTemplate1}" ItemsSource="{Binding Data1}" HorizontalAlignment="Center" >
    </GridView>
    </Grid>

    You could change the GridView's size to datatemplate size * 4 (and allow for any padding). This would have the side-effect of making the GridView a different size on different screens though (e.g. on a higher-resolution screen the grid will be smaller, but
    will have the correct number of rows).
    I'm not sure if it's possible, but see if you can adjust the datatemplate's size at runtime to be 1/4 the gridview size. This will scale nicely if it works.
    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.

  • How can I implement the equivilent of a temporary table with "on commit delete rows"?

    hi,
    I have triggers on several tables. During a transaction, I need to gather information from all of them, and once one of the triggers has all the information, it creates some data. I Can't rely on the order of the triggers.
    In Oracle and DB2, I'm using temporary tables with "ON COMMIT DELETE ROWS" to gather the information - They fit perfectly to the situation since I don't want any information to be passed between different transactions.
    In SQL Server, there are local temporary tables and global.  Local temp tables don't work for me since apparently they get deleted at the end of the trigger. Global tables keep the data between transactions.
    I could use global tables and add some field that identifies the transaction, and in each access to these tables join by this field, but didn't find how to get some unique identifier for the transaction. @@SPID is the session, and sys.dm_tran_current_transaction
    is not accessible by the user I'm supposed to work with.
    Also with global tables, I can't just wipe data when "operation is done" since at the triggers level I cannot identify when the operation was done, transaction was committed and no other triggers are expected to fire.
    Any idea which construct I could use to acheive the above - passing information between different triggers in the same transaction, while keeping the data visible to the current transaction?
    (I saw similar questions but didn't see an adequate answer, sorry if posting something that was already asked).
    Thanks!

    This is the scenario: If changes (CRUD) happen to both TableA and TableB, then log some info to TableC. Logic looks something like this:
    Create Trigger TableA_C After Insert on TableA {
      If info in temp tables available from TableB
            Write info to TableC
       else
           Write to temp tables info from TableA
    Create Trigger TableB_C After Insert on TableB {
      If info in temp tables available from TableA
            Write info to TableC
       else
           Write to temp tables info from TableB
    So each trigger needs info from the other table, and once everything is available, info to TableC is written. Info is only from the current transaction.
    Order of the triggers is not defined. Also there's no gurantee that both triggers would fire - changes can happen only to TableA / B and in that case I don't want to write anything to TableC.
    The part that gets and sets info to temp table is implemented as temp tables with "on commit delete rows" in DB2 / Oracle.
    What do you think? As I've mentioned, I could use global temp tables with a field that would identify the transaction, but didn't find something like that in SQL Server. And, the lifespan of local temp tables is too short.

  • Report layout supports each field listed vertically(1 field per row)

    I'm basically new to APEX. I have a report that displays 1 record of data with each field(1 per row) listed vertically. When using the default APEX report layout template, the Print attributes(.pdf, xml, online, HTML, etc.), every format prints all fields in one row. Can someone please provide the proper report layout that I can use to get my desired printout?

    This is the Oracle Reports forum. Post this in the Apex forum.

  • Percentage calculation in pivot table per row

    Hello all,
    I do calculate two fields in a pivot table. First calculated field is the # of activities per user (standard SoD reporting field). Second calculated field is the # of activities per user with a certain classification (customized pick list field that is converted in a from a text value to a integer value ==> CASE WHEN Activity.Type = 'Call' THEN 1 ELSE 0 END).
    In the pivot table I do show both vlaues as a sum. I would like to calculate the percentage per row per user.
    Example:
    User - # activities - # calls - percentage
    User XY - 80 - 40 - 50%
    Thanxs for your help
    Elmar

    have you # Call column look like
    sum(CASE WHEN Activity.Type = 'Call' THEN 1 ELSE 0 END) -- column2
    create the percentage column with # activities / column2
    under the column property of the percentage column --> Data Format -->Treat Numbers As --> percentage.
    leave the Aggregation Role as default on all columns.
    Hopefully, I didn't miss anything.
    Shilei

  • JDBC Inbound to separate IDOCS per Row instead of one single IDOC?

    Hello everyone,
    I'm currently working on the migration of our old B1iSN 8.8 scenarios to B1iSN 9.0.
    The scenario is the following: I have a SQL table with data and a separate control table where I store the date of the last run/data retrieval. My JDBC Inbound is triggered every day and the SQL Statement selects all new data between now and the last run. The process flow only consists of one transformation Atom which builds my custom idoc structure.
    In B1iSN 8.8 I've got one IDOC per row from the resultset. In the B1 9.0 outbound all rows are now withing one single IDOC. How can I trigger that separate IDOCS are created!?
    I've already tried the "Block Size" Setting. When I set it to "1" I get for two datasets two output IDOCS. However all data is in IDOC 1 and the second IDOC is empty. What is wrong here? How can I access the data in the current block? I currently use a "for each" on the normal jdbc resultset rows.
    I'm testing it at the moment with flat file output as our target system is not accessible yet, but I suppose this is not the reason?
    Thanks in advacne for any help.

    Hello André,
    please use a two-step approach with two integration scenarios:
    DB INBOUND -> VOID OUTBOUND
    INTERNAL QUEUE INBOUND -> ECC OUTBOUND
    In step one add a condtion including a for-each loop into your integration flow.
    Within this for-each please hand over for each IDoc you want to create into a second integration step via "Internal queue":
    The second step is triggered x-times via internal queue and does the field mapping into IDoc format.
    Best regards
    Bastian
    P.S.: with this approach, you can keep the block processing setting for DB INBOUND to an higher amount.

  • Rendering a table with more than one record per "row"

    Ok, it's like this. I have a collection that I want to render as an ADF Table with a single column. Except I want to render multiple entries in the collection per row of the table
    i.e. a normal ADF table would be like:
    [Column Header]
    [Row1.TextField]
    [Row2.TextField]
    [Row3.TextField]
    [Row4.TextField]
    [Row5.TextField]
    I would like to render it something like:
    [Column Header]
    [Row1.TextField] [Row2.TextField] [Row3.TextField]
    [Row4.TextField] [Row5.TextField]
    That is, I want to add each record's text field horizontally first before adding a new row vertically.
    Any way to do this with the ADF Table? Or is there another component I should use?

    Hi,
    you can try the "af:iterator" component
    example
    <af:panelGroupLayout id="pgl4" layout="horizontal">
                    <af:iterator id="i1" value="#{bindings.MyTree.collectionModel}"
                                 var="row" varStatus="vs">
                      <af:panelGroupLayout id="pgl5"
                                           rendered="#{(vs.index mod 3) eq 1}"
                                           inlineStyle="width:100px;"
                                           layout="horizontal">
                        <af:outputText value="#{row.CityCode}" id="ot2"/>
                      </af:panelGroupLayout>
                      <af:panelGroupLayout id="pgl6"
                                           rendered="#{(vs.index mod 3) eq 2}"
                                           inlineStyle="width:100px;"
                                           layout="horizontal">
                        <af:outputText value="#{row.CityCode}" id="outputText3"/>
                      </af:panelGroupLayout>
                      <af:panelGroupLayout id="pgl7"
                                           rendered="#{(vs.index mod 3) eq 0}"
                                           inlineStyle="width:100px;"
                                           layout="horizontal">
                        <af:outputText value="#{row.CityCode}" id="outputText4"/>
                      </af:panelGroupLayout>
                      <af:outputText value=" &lt;tr>" id="ot3" escape="false"
                                     rendered="#{(vs.index mod 3) eq 2}"/>
                    </af:iterator>
    </af:panelGroupLayout>Regards
    Nicolas

  • Purchase order discount per row error

    Dear all,
    I have a client who gets the following error when trying to post an Purchase order:
    "[Discount % per row] [Line 3], You are not permitted to perform this action"
    The purchase order is a service order and no accounts have been selected. Also the discount field is not visible or active on the purchase order. The user is not authorized to add discounts but he has not done so in the first place. What could the problem be?
    Regards,
    Anthony Njagi

    Hai!
    Even if Discount field is not active in Row Level, for service Type Documents when i change Total value more than once that is calculating the difference to Discount.
    Example:
    First i entered Total as INR1000
    I found that is wrong and changed to INR1200
    The Difference between INR1000 and INR1200 will go to Discount.
    To avoid this, ask user to type the amount in Unit Price Column instead of Total Column.
    Regards,
    Thanga Raj.K

  • Gauges Per Row in OBIEE 11.1.1.3

    Hi All,
    How do i set a dynamic value for the Gauges per row in the Gauge view based on the resulting data instead of setting a static value?
    Eg. For a particular selection if the data results to 2 records then 2 gauge.
    I will have a maximun of 5 gauges and fiixing the value to 5 is displaying blank space on the screen.
    Regards,
    Swati

    Could you Clear the browser cache and re-load the page or log in to OBIEE.
    if its not working then try to Re-deploy the Analytics Application, using the file $Middleware_Home\Oracle_BI1\bifoundation\jee\analytics.ear
    Do let me know for any updates?

  • Commit causes rows to disappear [solved: rogue client]

    I just ran into the strangest thing.
    Running XE 11g on Linux and Apex. My apex app was acting strange so I went into SQLDeveloper to run the raw commands that the apex app was supposed to be running.
    I ran two insert statements, inserting data into a table (insert into a table using a select).
    Then I did a select from the table to verify that the rows were there.
    The two rows were there. They looked exactly as I had inserted them.
    Then I issued a commit.
    Guess what happened? My two rows were GONE!
    I did this multiple times, each time I got the same result, the rows were gone AFTER the commit! There were no errors thrown in sqlDeveloper and nothing in the alert_XE.log.
    Not knowing what else to do, I restarted the database (shutdown immediate; startup;). I reconnected and ran the exact same inserts and commits an it worked! The rows where there and my Apex app was working fine.
    I've been an Oracle Programmer or DBA since 1994 and have never seen anything like this. The database has been up for 120 days and my only non-system generated tablespace is 20Meg.
    The table in question has some unique constraints, but my statements didn't conflict and no errors were thrown. I'd try to open an SR, but there isn't a trace or anything to submit.
    Anyone else seen this behavior in XE 11g?
    Edited by: mcallister on Aug 24, 2012 8:29 AM

    OS Details:
    CentOS 5 x64 kernel 2.6.18-308.4.1.el5
    Pentium 4 with 1 gig of RAM
    The /u01 mount point has 73 gigs of free space and the tablespace the table is in is only 20 meg in size.
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production.
    The only errors in the alert_XE.log are:
    Sun Aug 19 03:00:00 2012
    Errors in file /u01/app/oracle/diag/rdbms/xe/XE/trace/XE_j000_23033.trc:
    ORA-12012: error on auto execute of job "SYS"."BSLN_MAINTAIN_STATS_JOB"
    ORA-06550: line 1, column 807:
    PLS-00201: identifier 'DBSNMP.BSLN_INTERNAL' must be declared
    ORA-06550: line 1, column 807:
    PL/SQL: Statement ignoredThe errors occur periodically and have been there since the database was created on 26-Feb-2012.
    The table is NOT a global temporary table. No one has access to the database but me, everyone else uses the Apex app that I built. On 21-Aug-2012 a user of my site reported that he was unable to reserve a tee time for his golf league via the Apex application. I tried as well and got the same result. I went into the Apex app designer, found the pl/sql package that makes the reservation call, made the exact same call in SQLDeveloper and the row was inserted into the table. I issued a commit so that I could see the tee time reservation on the web site and it was NOT there. I did this repeatedly.
    Confused, I eventually just wrote a single insert statement in SQL Developer to insert the rows manually.
    1) I inserted one row, then changed the statement to avoid the unique constraint on the table.
    2) inserted another row
    3) then did a select on the table to see that both rows were there. They were both there.
    4) then issued a commit followed by the same select as step 3. Both rows were GONE.
    There was no error in the alert log. After I restarted the database, I repeated the same procedure as above with the exact same data and after the commit the rows were in the table just as they should be. The application is now working correctly.
    Table details:
    SELECT table_name, tablespace_name, temporary, duration
    FROM all_tables
    WHERE table_name = 'MATCH_TEE_TIMES';
    TABLE_NAME                     TABLESPACE_NAME                TEMPORARY DURATION       
    MATCH_TEE_TIMES                FACULTYSTAFFGOLF               N        Frankly, I'm very concerned. This is a data loss scenario with no outward signs of error. I've been running Oracle databases since 1994 and never seen anything like this. I run four mission-critical 11g Enterprise Edition databases in my professional life and my employer has hundreds of others that keep our university working. Granted none of them are XE, but if this is a common bug we would be in really big trouble.

  • WITH Subquery Factoring OR "Scalar SubqueriesRun Another Query per row

    Hi Experts
    Please suggest
    which one query is better
    Involved table p is of size 2GB and c1/c2 of size 800M.
    And we have to run a report on p which will do FTS (no where clause on p)
    So FTS on 2 GB table and then running Another Query per row .. so results job very slow
    1)  Select p.id,
             (select sum(q1) from c1 where c1.id = p.id) c1_sum1,
             (select sum(q2) from c2 where c2.id = p.id) c2_sum2
       from p
    2)
    WITH Subquery Factoring
    with c1_vw as
    (select id, sum(q1) c1_sum1
        from c1
             group by id),
       c2_vw as
       (select id, sum(q2) c2_sum2
           from c2
          group by id),
       c1_c2 as
       (select c1.id, c1.c1_sum1, c2.c2_sum2
           from c1_vw c1, c2_vw c2
          where c1.id = c2.id )
       select p.id, c1_sum1, c2_sum2
          from p, c1_c2
         where p.id = c1_c2.id
       / 10.2..0.4
    AIX 5.3
    Thanks In Advance
    ivw

    ivw wrote:
    which one query is betterThe better query IMHO is the one that returns the the correct results in the shortest amount of time using the least system resources (the last two items usually happen at the same time). Maintainability is an issue too. Which one do you like best?
    Its hard to say which query will run best without running both, getting execution plans, and run-time statistics. At a pure guess I would think all things being equal they would have similar performance but do not really know.

  • Cannot commit delete row from VO

    I have a VO that I have no problem create new row, update existing row and commit. But I can't commit deleted row to database. no exception or error message etc... and All other VOs are working fine,
    anybody has any idea why? is that an option or something on VO? or is it an BC4J bug?
    Thanks,
    -Ming
    Edited by: user715460 on Oct 16, 2008 3:40 PM

    You are in the wrong forum. Try your question JDeveloper and ADF .
    And please consider this too (copied from this thread Concerned in delayed response
    a) Use a good subject line that briefly describes the issue. This will attract those familiar with that area to come and help.
    b) Tell us what database version you are using. Not just saying e.g. "10g" but more specifically "10.2.0.3"
    c) Describe the issue clearly stating what you have tried, and what you are trying to achieve.
    d) Don't use txt spk because this is a professional forum, not a chat room and not everyone can follow it.
    e) Don't USE CAPITAL LETTERS IN YOUR DESCRIPTION as this is considered shouting and agressive.
    f) Provide sample data for us to use if necessary either with the CREATE TABLE and INSERT statements to create it or providing a WITH clause that we can use. This saves us from having to type in and format the sample data for ourselves and is more likely to attract us to help.
    g) Show the code that you have already tried (if you haven't tried any code yet then why not? have a go yourself and only ask for help when you get stuck).
    h) Show us any error messages you are getting, in full, and with information of the line numbers where the error is occurring
    i) Wherever you provide data or code remember to use the tag before and after or the [code] tag before and the [/code] tag after, so that it keeps it's layout and is clear to read.
    j) Perhaps one of the most important things of all... never suggest that you need a solution "urgently" or that your issue is "urgent". This implies that your issue is somehow more important than the issues posted by other people. Everybody would like an answer to their issue promptly, but it just depends when people are online who can answer the question and nobody is being paid to answer it, so it is arrogant and rude to demand urgent attention to your own. If something is that urgent then you should raise it through oracle metalink as a priority issue or pay for someone with the necessary skills to come and do the work for you.
    Timo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Setting Up a New User Account - iTunes issue

    My wife and I were both using our Mac as a single user, but logging into iTunes under separate iTunes accounts to download our own music and apps. This week I set up a new User Account in her name, and transferred all music and apps to her User Accou

  • Table maintenance view -user exit

    Hello, as you all know, there is a program generated behind the table maintenance view. I want to add certain validation on the values entered in the table maintenance. I know that modifying the program is not the best practice. Is there any user exi

  • Connecting to Outlook Global Address List

    I have an application which needs to email the contents of a record to one or more people in our Outlook Global Address List. I would like to present the user with the GAL so he/she may pick the recipient. Anybody done this?

  • HP Officejet4630 All-in-One

    Orginal black in cartridge expired and I purchased two new black cartridges through HP. Twin-pack showing HP on the box with the number 61. The package the cartridges come in show the number CH561W HP 61 and so do the cartridges in side. I opened the

  • What does this line of code do: ?xml version="1.0" encoding="windows-1252"?

    When I add this code to a new xhtml file and validate for XML I get the following error: Character Encoding mismatch! [XHTML 1.0 Transitional]