Duplicate row added when inserting programticaly

hi am inserting row programaticaly,this is what i have done create a view with Transient attributes ,the view have two table usertable and organisationuser table,what am doing am inserting username in organisationuser from usertable ,but at the same time trying to display the username details like firstname,surname,email,which am trying to dispaly them through the Transient attributes,but now when i click the add button to add it show like it insert two rows but when i go to datanase it has only insert one row which is correct,am in jdeveloper 11.1.1.6.0
Edited by: adf009 on 2013/03/01 9:53 AM
Edited by: adf009 on 2013/03/05 11:02 AM

hi this is the query am using
the target VO WHICH I i what to insert values is
<?xml version="1.0" encoding="windows-1252" ?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<!---->
<ViewObject
  xmlns="http://xmlns.oracle.com/bc4j"
  Name="DeltMember"
  Version="11.1.1.61.92"
  InheritPersonalization="true"
  BindingStyle="OracleName"
  CustomQuery="false"
  PageIterMode="Full"
  UseGlueCode="false"
  RowClass=model.UpdOrgDetails.DeltMemberRowImpl"
  ComponentClass=model.UpdOrgDetails.DeltMemberImpl"
  FromList="UAM_ORGANISATION_USER UamOrganisationUser, UAM_USERDETAILS UamUserdetails, UAM_ORGANISATIONS UamOrganisations"
  Where="(UamOrganisationUser.USERNAME = UamUserdetails.USERNAME) AND (UamOrganisationUser.ORGANISATIONID = UamOrganisations.ORGANISATIONID)"
  SelectList="UamOrganisationUser.ORGANISATIONID,
       UamOrganisationUser.USERNAME,
       UamUserdetails.SURNAME,
       UamUserdetails.USERNAME AS USERNAME1,
       UamUserdetails.FIRSTNAME,
       UamUserdetails.EMAILADDRESS,
       UamOrganisations.ORGANISATIONID AS ORGANISATIONID1,
       UamOrganisationUser.CREATED_DATE">
  <DesignTime>
    <Attr Name="_codeGenFlag2" Value="Access|Coll|Prog|VarAccess"/>
    <Attr Name="_isCodegen" Value="true"/>
  </DesignTime>
  <Properties>
    <SchemaBasedProperties>
      <LABEL
        ResId=model.UpdOrgDetails.DeltMember_LABEL"/>
    </SchemaBasedProperties>
  </Properties>
  <EntityUsage
    Name="UamOrganisationUser"
    Entity=model.entities.UamOrganisationUser"/>
  <EntityUsage
    Name="UamUserdetails"
    Entity=model.entities.UamUserdetails"
    Association=model.entities.OrguserlinkUserdetailsFkAssoc"
    AssociationEnd=model.entities.OrguserlinkUserdetailsFkAssoc.UamUserdetails"
    SourceUsage=model.UpdOrgDetails.DeltMember.UamOrganisationUser"
    ReadOnly="true"
    Reference="true"
    DeleteParticipant="false"
    JoinType="INNER JOIN">
    <DesignTime>
      <AttrArray Name="_srcAttributes">
        <Item
          Value=model.entities.UamOrganisationUser.Username"/>
      </AttrArray>
      <AttrArray Name="_dstAttributes">
        <Item
          Value=model.entities.UamUserdetails.Username"/>
      </AttrArray>
    </DesignTime>
  </EntityUsage>
  <EntityUsage
    Name="UamOrganisations"
    Entity=model.entities.UamOrganisations"
    Association=model.entities.OrguserlinkOrganisationsFkAssoc"
    AssociationEnd=model.entities.OrguserlinkOrganisationsFkAssoc.UamOrganisations"
    SourceUsage=model.UpdOrgDetails.DeltMember.UamOrganisationUser"
    ReadOnly="true"
    Reference="true"
    DeleteParticipant="false"
    JoinType="INNER JOIN">
    <DesignTime>
      <AttrArray Name="_srcAttributes">
        <Item
          Value=model.entities.UamOrganisationUser.Organisationid"/>
      </AttrArray>
      <AttrArray Name="_dstAttributes">
        <Item
          Value=model.entities.UamOrganisations.Organisationid"/>
      </AttrArray>
    </DesignTime>
  </EntityUsage>
  <ViewAttribute
    Name="firstnameT"
    IsSelected="false"
    IsPersistent="false"
    PrecisionRule="true"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="VIEW_ATTR"
    SQLType="VARCHAR">
    <RecalcCondition><![CDATA[true]]></RecalcCondition>
    <TransientExpression><![CDATA[Firstname]]></TransientExpression>
    <Dependencies>
      <Item
        Value="Firstname"/>
    </Dependencies>
  </ViewAttribute>
  <ViewAttribute
    Name="SurnameT"
    IsSelected="false"
    IsPersistent="false"
    PrecisionRule="true"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="VIEW_ATTR"
    SQLType="VARCHAR">
    <RecalcCondition><![CDATA[true]]></RecalcCondition>
    <TransientExpression><![CDATA[Surname]]></TransientExpression>
    <Dependencies>
      <Item
        Value="Surname"/>
    </Dependencies>
  </ViewAttribute>
  <ViewAttribute
    Name="EmailT"
    IsSelected="false"
    IsPersistent="false"
    PrecisionRule="true"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="VIEW_ATTR"
    SQLType="VARCHAR">
    <RecalcCondition><![CDATA[true]]></RecalcCondition>
    <TransientExpression><![CDATA[Emailaddress]]></TransientExpression>
    <Dependencies>
      <Item
        Value="Emailaddress"/>
    </Dependencies>
  </ViewAttribute>
  <ViewAttribute
    Name="Organisationid"
    IsUpdateable="while_insert"
    IsNotNull="true"
    PrecisionRule="true"
    EntityAttrName="Organisationid"
    EntityUsage="UamOrganisationUser"
    AliasName="ORGANISATIONID">
    <TransientExpression><![CDATA[Organisationid1]]></TransientExpression>
  </ViewAttribute>
  <ViewAttribute
    Name="Username"
    IsNotNull="true"
    PrecisionRule="true"
    EntityAttrName="Username"
    EntityUsage="UamOrganisationUser"
    AliasName="USERNAME">
    <TransientExpression><![CDATA[Username1]]></TransientExpression>
    <Dependencies>
      <Item
        Value="Username1"/>
    </Dependencies>
  </ViewAttribute>
  <ViewAttribute
    Name="Surname"
    IsNotNull="true"
    PrecisionRule="true"
    EntityAttrName="Surname"
    EntityUsage="UamUserdetails"
    AliasName="SURNAME"/>
  <ViewAttribute
    Name="Username1"
    IsNotNull="true"
    PrecisionRule="true"
    EntityAttrName="Username"
    EntityUsage="UamUserdetails"
    AliasName="USERNAME1"
    IsUpdateable="false"/>
  <ViewAttribute
    Name="Firstname"
    IsNotNull="true"
    PrecisionRule="true"
    EntityAttrName="Firstname"
    EntityUsage="UamUserdetails"
    AliasName="FIRSTNAME"
    IsUpdateable="false"/>
  <ViewAttribute
    Name="Emailaddress"
    IsNotNull="true"
    PrecisionRule="true"
    EntityAttrName="Emailaddress"
    EntityUsage="UamUserdetails"
    AliasName="EMAILADDRESS"/>
  <ViewAttribute
    Name="Organisationid1"
    IsUpdateable="false"
    IsNotNull="true"
    PrecisionRule="true"
    EntityAttrName="Organisationid"
    EntityUsage="UamOrganisations"
    AliasName="ORGANISATIONID1"/>
  <ViewAttribute
    Name="CreatedDate"
    PrecisionRule="true"
    EntityAttrName="CreatedDate"
    EntityUsage="UamOrganisationUser"
    AliasName="CREATED_DATE"/>
  <AttrArray Name="KeyAttributes">
    <Item Value="Organisationid"/>
    <Item Value="Username"/>
  </AttrArray>
  <ResourceBundle>
    <PropertiesBundle
      PropertiesFile="model.ModelBundle"/>
  </ResourceBundle>
</ViewObject>
my bean code is
    public void addMember(javax.faces.event.ActionEvent actionEvent) {
        List<String> tempTable = new ArrayList<String>();
        //Code to get the bindings for TargetVO :
             RowKeySet selectedEmps = getEmpTable().getSelectedRowKeys();   
               Iterator selectedEmpIter = selectedEmps.iterator();
               DCBindingContainer bindings =
                                 (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
               DCIteratorBinding empIter = bindings.findIteratorBinding("UserDetailsViewVO1Iterator");
               RowSetIterator empRSIter = empIter.getRowSetIterator();
                while(selectedEmpIter.hasNext()){
                  Key key = (Key)((List)selectedEmpIter.next()).get(0);
                  Row currentRow = empRSIter.getRow(key);
                      onRowCreate(currentRow);
    public void onRowCreate( Row currentRow ) {
        UAMAppModuleImpl am = (UAMAppModuleImpl)ADFUtils.getApplicationModuleForDataControl("UAMAppModuleDataControl1");      
        OIDOperations   oIDOperations= new  OIDOperations();
      //  Map<Object,String> mp=new HashMap<Object, String>();
     BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
     //access the name of the iterator the table is bound to.
     DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("DeltMember1Iterator");
     //access the underlying RowSetIterator
     RowSetIterator rsi = dciter.getRowSetIterator();
     //get handle to the last row
     Row lastRow = rsi.last();
     //obtain the index of the last row
     int lastRowIndex = rsi.getRangeIndexOf(lastRow);
     /*check if the user is added already*/
     /*OperationBinding oper2 = (OperationBinding) bindings.get("check if user exists method binding");
     oper2.getParamsMap().put("attributeName1", uniqueUserAttributeValue);
     Object ret = oper2.execute();*/
     //create a new row
          EntityDefImpl accDef =UamOrganisationUserImpl.getDefinitionObject();
          UamOrganisationUserImpl org =    (UamOrganisationUserImpl)accDef.createInstance2(am.getDBTransaction(),null);
     //create a new row
     Row newRow = rsi.createRow();
     String f = (String)currentRow.getAttribute("Firstname");
     String s = (String)currentRow.getAttribute("Surname");
     String u = (String)currentRow.getAttribute("Username"); 
     String n = (String)currentRow.getAttribute("Emailaddress");
        newRow.setAttribute("firstnameT", f);
        newRow.setAttribute("SurnameT", s);
        newRow.setAttribute("Username", u);
        newRow.setAttribute("EmailT", n);
     //initialize the row
     newRow.setNewRowState(Row.STATUS_INITIALIZED);
     //add row to last index + 1 so it becomes last in the range set
     rsi.insertRowAtRangeIndex(lastRowIndex +1,  newRow);
     //make row the current row so it is displayed correctly
     rsi.setCurrentRow(newRow);
      org.setOrganisationid(getorgid());
                org.setUsername(u);
                org.setOrguserrole(oIDOperations.UserType());
                am.getDBTransaction().commit();
    //  mp.put(u,u);
      //          oIDOperations.assignRoleToUsers(getorgname(), mp);
     System.out.println("orgupdated " +getorgname());
       // System.out.println("usradded "+mp);
        System.out.println("Username " + u);
        System.out.println("firstname " + f);
        System.out.println("surname " + s);
        System.out.println("email " + n);
       // refereshpage();
    // return null;
my jsff two table page is
<af:table value="#{bindings.UserDetailsViewVO1.collectionModel}"
                                var="row"
                                rows="#{bindings.UserDetailsViewVO1.rangeSize}"
                                emptyText="#{bindings.UserDetailsViewVO1.viewable ? 'No data to display.' : 'Access Denied.'}"
                                fetchSize="#{bindings.UserDetailsViewVO1.rangeSize}"
                                rowBandingInterval="0"
                                selectedRowKeys="#{bindings.UserDetailsViewVO1.collectionModel.selectedRow}"
                                selectionListener="#{bindings.UserDetailsViewVO1.collectionModel.makeCurrent}"
                                rowSelection="single"
                                partialTriggers="::qryId1" id="t4"
                                inlineStyle="height:219px;" width="718"
                                columnStretching="last"
                                binding="#{pageFlowScope.addMember.empTable}">
                        <af:column sortProperty="Username" sortable="false"
                                   headerText="#{bindings.UserDetailsViewVO1.hints.Username.label}"
                                   id="c10">
                          <af:outputText value="#{row.Username}" id="ot1"/>
                        </af:column>
                        <af:column sortProperty="Firstname" sortable="false"
                                   headerText="#{bindings.UserDetailsViewVO1.hints.Firstname.label}"
                                   id="c9">
                          <af:outputText value="#{row.Firstname}" id="ot3"/>
                        </af:column>
                        <af:column sortProperty="Surname" sortable="false"
                                   headerText="#{bindings.UserDetailsViewVO1.hints.Surname.label}"
                                   id="c12">
                          <af:outputText value="#{row.Surname}" id="ot2"/>
                        </af:column>
                        <af:column sortProperty="Emailaddress" sortable="false"
                                   headerText="#{bindings.UserDetailsViewVO1.hints.Emailaddress.label}"
                                   id="c11">
                          <af:outputText value="#{row.Emailaddress}" id="ot4"/>
                        </af:column>
                        <af:column id="c16">
                          <af:commandButton text="Add New" id="cb5"
                                            actionListener="#{pageFlowScope.addMember.addMember}"/>
                        </af:column>
                      </af:table>
                    </af:panelGroupLayout>
                  </af:panelHeader>
                </af:panelGroupLayout>
              </af:panelGroupLayout>
            </af:panelHeader>
            <af:panelHeader text="Member In Organisation" id="ph8"
                            inlineStyle="border-color:Navy; border-style:ridge; width:857px;">
              <f:facet name="context">
                <af:toolbar id="t10"/>
              </f:facet>
              <f:facet name="menuBar"/>
              <f:facet name="toolbar"/>
              <f:facet name="legend"/>
              <f:facet name="info"/>
              <af:table value="#{bindings.DeltMember1.collectionModel}"
                        var="row" rows="#{bindings.DeltMember1.rangeSize}"
                        emptyText="#{bindings.DeltMember1.viewable ? 'No data to display.' : 'Access Denied.'}"
                        fetchSize="#{bindings.DeltMember1.rangeSize}"
                        rowBandingInterval="0"
                        selectedRowKeys="#{bindings.DeltMember1.collectionModel.selectedRow}"
                        selectionListener="#{bindings.DeltMember1.collectionModel.makeCurrent}"
                        rowSelection="single" id="t5" width="601"
                        partialTriggers="cb9">
                <af:column sortProperty="firstnameT" sortable="false"
                           headerText="#{bindings.DeltMember1.hints.firstnameT.label}"
                           id="c13">
                  <af:inputText value="#{row.bindings.firstnameT.inputValue}"
                                label="#{bindings.DeltMember1.hints.firstnameT.label}"
                                required="#{bindings.DeltMember1.hints.firstnameT.mandatory}"
                                columns="#{bindings.DeltMember1.hints.firstnameT.displayWidth}"
                                maximumLength="#{bindings.DeltMember1.hints.firstnameT.precision}"
                                shortDesc="#{bindings.DeltMember1.hints.firstnameT.tooltip}"
                                id="it7">
                    <f:validator binding="#{row.bindings.firstnameT.validator}"/>
                  </af:inputText>
                </af:column>
                <af:column sortProperty="SurnameT" sortable="false"
                           headerText="#{bindings.DeltMember1.hints.SurnameT.label}"
                           id="c14">
                  <af:inputText value="#{row.bindings.SurnameT.inputValue}"
                                label="#{bindings.DeltMember1.hints.SurnameT.label}"
                                required="#{bindings.DeltMember1.hints.SurnameT.mandatory}"
                                columns="#{bindings.DeltMember1.hints.SurnameT.displayWidth}"
                                maximumLength="#{bindings.DeltMember1.hints.SurnameT.precision}"
                                shortDesc="#{bindings.DeltMember1.hints.SurnameT.tooltip}"
                                id="it11">
                    <f:validator binding="#{row.bindings.SurnameT.validator}"/>
                  </af:inputText>
                </af:column>
                <af:column sortProperty="EmailT" sortable="false"
                           headerText="#{bindings.DeltMember1.hints.EmailT.label}"
                           id="c15">
                  <af:inputText value="#{row.bindings.EmailT.inputValue}"
                                label="#{bindings.DeltMember1.hints.EmailT.label}"
                                required="#{bindings.DeltMember1.hints.EmailT.mandatory}"
                                columns="#{bindings.DeltMember1.hints.EmailT.displayWidth}"
                                maximumLength="#{bindings.DeltMember1.hints.EmailT.precision}"
                                shortDesc="#{bindings.DeltMember1.hints.EmailT.tooltip}"
                                id="it6">
                    <f:validator binding="#{row.bindings.EmailT.validator}"/>
                  </af:inputText>
                </af:column>
                <af:column id="c17">
                  <af:commandButton actionListener="#{bindings.Delete1.execute}"
                                    text="Delete1"
                                    id="cb9"/>
                </af:column>
              </af:table>Edited by: adf009 on 2013/03/07 9:21 AM

Similar Messages

  • Duplicate column name when inserting a batch to biztalk

    I wonder why I get the following error:
    The adapter failed to transmit message going to send port "SEND_PORT_TESTORCHESTRATION_00010" with URL "oracledb://OracleServer/?PollingId=TEST_ORCHESTRATION_ORACLE_00010". It will be retransmitted after the retry interval specified for
    this Send Port. Details:"Microsoft.ServiceModel.Channels.Common.TargetSystemException: ORA-06550: line 2, column 290:
    PL/SQL: ORA-00957: duplicate column name
    ORA-06550: line 2, column 1:
    PL/SQL: SQL Statement ignored ---> Oracle.DataAccess.Client.OracleException: ORA-06550: line 2, column 290:
    PL/SQL: ORA-00957: duplicate column name
    ORA-06550: line 2, column 1:
    PL/SQL: SQL Statement ignored
       at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
       at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
       at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
       at Microsoft.Adapters.OracleCommon.OracleCommonUtils.ExecuteNonQuery(OracleCommand command, OracleCommonExecutionHelper executionHelper)
       --- End of inner exception stack trace ---
    When I tried to pull a batch from sql server to insert to an oracle table. I have checked and none of the records were duplicate or had the same key. If I sent a batch of only 1 record, it went through fine and oracle database was updated.
    However, in either cases, no response from Oracle were received. I had a FILE port to save oracle response to file because the oracle port in the orchestration was 2 way (Send/Receive) port.
    Why was BizTalk not writing the response to file?
    Your hint/instruction to shed some light to this mystery is highly appreciated. Thanks!
    Note: When I tried to look the orchestration debugger, I saw the same message from sql being transmitted twice...why is BizTalk doing that?

    Hi BoatSeller,
    I think it may be something related to the map, I just do not know what. This is what I saw from the message part:
    <ns0:Insert xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/ORACLETABLE/Table/ROTATION_REQ">
    <ns0:RECORDSET>
    <ns0:ROTATION_REQRECORDINSERT>
    <ns0:RotationID>D4-2015-CO1</ns0:RotationID>
    <ns0:RotationID>D4-015-GL1</ns0:RotationID>
    <ns0:Year>2015</ns0:Year>
    <ns0:Year>2015</ns0:Year>
    <ns0:Class>D4</ns0:Class>
    <ns0:Class>D4</ns0:Class>
    <ns0:Rotation>CROSSOVER</ns0:Rotation>
    <ns0:Rotation>GOOCHLAND CLINIC</ns0:Rotation>
    <ns0:From>2014-08-06</ns0:From>
    <ns0:From>2014-05-20</ns0:From>
    <ns0:To>2015-03-05</ns0:To>
    <ns0:To>2015-03-05</ns0:To>
    <ns0:NumberOfConsecutiveSession>1</ns0:NumberOfConsecutiveSession>
    <ns0:NumberOfConsecutiveSession>1</ns0:NumberOfConsecutiveSession>
    <ns0:AmOrPM InlineValue="1"></ns0:AmOrPM>
    <ns0:AmOrPM InlineValue="2"></ns0:AmOrPM>
    <ns0:DayOfWeek>5</ns0:DayOfWeek>
    <ns0:DayOfWeek>4</ns0:DayOfWeek>
    </ns0:ROTATION_REQRECORDINSERT>
    </ns0:RECORDSET>
    </ns0:Insert>
    I thought that would be an issue because it looks like it was repeating the content, but if I understand you correctly, this is what the message content supposed to be? If not, what should I change in the map so that Oracle will get the following?
    <Record1> <field1>..</field1><field2>..</field2></Record1>
    <Record2> <field1>..</field1><field2>..</field2></Record2>
    This is the print screen of my orchestration debugger:
    If this is a problem, how should I fix this?
    And this is my mapping:
    Thanks,

  • Loading a flat table with duplicate rows in SQL server

    Hi,
    I'm trying to load a flat table with different levels that has duplicate rows. When I'm loading it from my source SQL server enviornment to target SQL server environment.. I can only load 63 rows out of the 1225 rows.. This is happenning because i had to define a primary key on the couple of columns..
    When I just try to load it without a primary key, I get an error that PK needs to be defined for load to happen..
    My table structure looks as follows -
    Lvl1 Lvl2 Lvl3 Lvl4 AccountID AccountDesc
    How do i load all rows of data in my target table using ODI?\
    Please help

    whirlpool wrote:
    Hi,
    I'm trying to load a flat table What is a flat table ? Are you talking about FACT table ?
    When I'm loading it from my source SQL server enviornment to target SQL server environment.. I can only load 63 rows out of the 1225 rows.. This is happenning because i had to define a primary key on the couple of columns..
    When I just try to load it without a primary key, I get an error that PK needs to be defined for load to happen..
    Which IKM is in use ? I can not remember an IKM which needs a PK . Incremental Update IKM needs a Update key which can be a PK or UK at database level or ODI level.
    My table structure looks as follows -
    Lvl1 Lvl2 Lvl3 Lvl4 AccountID AccountDesc
    How do i load all rows of data in my target table using ODI?\
    If you not bother about PK at target then you can go for SQL Control Append to load your target table.
    Thanks,
    Sutirtha

  • Wierd duplicate rows problem

    Hi,
    I've a partitioned table and when I query to extract primary keys for a particular month, I'm getting wierd results. Here is what is happening -
    SELECT colA, colB, colC
    FROM tableA partition(Y06M01)
    WHERE current = 'Y'
    -- This query is returning me some duplicate rows for colA, colB, colC when these columns form primary key on tableA. Note that, rowids for these rows are not repeating, which makes me think oracle is actually storing these duplicate rows on the drive.
    Now, for the values that are repeating in the above query, following query doesnt result in duplicate rows (note that I'm not mentioning partition name in the from clause) -
    SELECT colA, colB, colC
    FROM tableA
    WHERE current = 'Y'
    AND (
    (colA = <val1> AND colB = <val2> AND colC = <val3>)
    OR
    (colA = <val4> AND colB = <val5> AND colC = <val6>)
    OR
    (colA = <val7> AND colB = <val8> AND colC = <val9>)
    Does anyone know why such a thing is happening? is it some kind of internal oracle error?
    Thanks

    Answers to your questions
    FROM tableA partition(Y06M01)Why have you need to query against the partition instead of table level ?
    -- There's no need, but the rows that are repeating lie in this partition. Hence, querying against the partition or against the table should return same results.
    colA, colB, colC when these columns form primary key on tableAAre they a primary key created ?
    -- Yes there's is a primary key created on these columns.
    Anyway, have you just some example output to show us.
    -- Here is the sample output:
    Scenario I (If I query against the partition). In this case if i extract rowids, they are different for each of below selected 6 rows
    colA colB colC
    1 2 3
    4 5 6
    4 5 6
    4 5 6
    7 8 9
    7 8 9
    Scenario II (If I query against the table for values (1,2,3), (4,5,6) and (7,8,9))
    colA colB colC
    1 2 3
    4 5 6
    7 8 9
    Furthermore, generally, to see the duplicate rows, try this query :
    select colA, colB, colC, count(*)
    from tableA
    having count(*)>1;
    -- I did run this query and again if I query against the partition I see duplicate rows and when I query against the table there are no duplicate rows.

  • How to delete the duplicate rows present in the parent table & insert the latest duplicate record into the parent table linked with the child table.

    I have a master table and i need to import the rows into the parent and child table.
    Master table name is Flatfile_Inventory
    Parent Table name is INVENTORY
    Child Tables name are INVENTORY_AMOUNT,INVENTORY_DETAILS,INVENTORY_VEHICLE,
    Error details will be goes to LOG_INVENTORY_ERROR
    I have 4 duplicate rows in the Flatfile_Inventory which i have already inserted in the Parent and child table.
    Again when i run the query using stored procedure,
    its tells that all the 4 rows are duplicate and will move to the Log_Inventory_Error.
    I need is if i have the duplicate rows in the flatfile_Inventory when i start inserting into the parent and child table the already inserted row have the unique ID i
    must identify it and delete that row in the both parent and chlid table.And latest row must get inserted into the Parent and child table from Flatfile_Inventory.
    Please help me to write the query i have attached the Full stored procedure Script..
    Arunraj Kumar

    Hi Santhosh,
    This is my Script.
    -- =============================================
    -- Stored Procedure for FLATFILE_INVENTORY
    -- =============================================
    -- Drop stored procedure if it already exists
       DROP PROCEDURE SP_Flatfile_Inventory
    GO
    CREATE PROCEDURE SP_Flatfile_Inventory
    AS
    --USE IconicMarketing
    GO
    DECLARE
    @FileType  varchar(50)  ,
    @ACDealerID  varchar(50)  ,
    @ClientDealerID  varchar(50)  ,
    @DMSType  varchar(50)  ,
    @StockNumber  varchar(50)  ,
    @InventoryDate  datetime  ,
    @StockType  varchar(100)  ,
    @DMSStatus  varchar(50)  ,
    @InvoicePrice  numeric(18, 2)  ,
    @CostPack  varchar(50)  ,
    @SalesCost  numeric(18, 2)  ,
    @HoldbackAmount  numeric(18, 2)  ,
    @ListPrice  numeric(18, 2)  ,
    @MSRP  varchar(max)  ,
    @LotLocation  varchar(50)  ,
    @TagLine  varchar(max)  ,
    @Certification  varchar(max)  ,
    @CertificationNumber  varchar(max)  ,
    @VehicleVIN  varchar(50)  ,
    @VehicleYear  bigint  ,
    @VehicleMake  varchar(50)  ,
    @VehicleModel  varchar(50)  ,
    @VehicleModelCode  varchar(50)  ,
    @VehicleTrim  varchar(50)  ,
    @VehicleSubTrimLevel  varchar(max)  ,
    @Classification  varchar(max)  ,
    @TypeCode  varchar(100)  ,
    @VehicleMileage  bigint  ,
    @EngineCylinderCount  bigint  ,
    @TransmissionType  varchar(50)  ,
    @VehicleExteriorColor  varchar(50)  ,
    @VehicleInteriorColor  varchar(50)  ,
    @CreatedDate  datetime  ,
    @LastModifiedDate  datetime  ,
    @ModifiedFlag  varchar(max)  ,
    @InteriorColorCode  varchar(50)  ,
    @ExteriorColorCode  varchar(50)  ,
    @PackageCode  varchar(50)  ,
    @CodedCost  varchar(50)  ,
    @Air  varchar(100)  ,
    @OrderType  varchar(max)  ,
    @AgeDays  bigint  ,
    @OutstandingRO  varchar(50)  ,
    @DlrAccessoryRetail  varchar(50)  ,
    @DlrAccessoryCost  varchar(max)  ,
    @DlrAccessoryDesc  varchar(max)  ,
    @ModelDesc  varchar(50)  ,
    @Memo1  varchar(1000)  ,
    @Memo2  varchar(max)  ,
    @Weight  varchar(max)  ,
    @FloorPlan  numeric(18, 2)  ,
    @Purchaser  varchar(max)  ,
    @PurchasedFrom  varchar(max)  ,
    @InternetPrice  varchar(50)  ,
    @InventoryAcctDollar  numeric(18, 2)  ,
    @VehicleType  varchar(50)  ,
    @DealerAccessoryCode  varchar(50)  ,
    @AllInventoryAcctDollar  numeric(18, 2)  ,
    @BestPrice  varchar(50)  ,
    @InStock  bigint  ,
    @AccountingMake  varchar(50)  ,
    @GasDiesel  varchar(max)  ,
    @BookValue  varchar(10)  ,
    @FactoryAccessoryDescription  varchar(max)  ,
    @TotalReturn  varchar(10)  ,
    @TotalCost  varchar(10)  ,
    @SS  varchar(max)  ,
    @VehicleBody  varchar(max)  ,
    @StandardEquipment  varchar(max)  ,
    @Account  varchar(max)  ,
    @CalculatedPrice  varchar(10)  ,
    @OriginalCost  varchar(10)  ,
    @AccessoryCore  varchar(10)  ,
    @OtherDollar  varchar(10)  ,
    @PrimaryBookValue  varchar(10)  ,
    @AmountDue  varchar(10)  ,
    @LicenseFee  varchar(10)  ,
    @ICompany  varchar(max)  ,
    @InvenAcct  varchar(max)  ,
    @Field23  varchar(max)  ,
    @Field24  varchar(max)  ,
    @SalesCode  varchar(max)  ,
    @BaseRetail  varchar(10)  ,
    @BaseInvAmt  varchar(10)  ,
    @CommPrice  varchar(10)  ,
    @Price1  varchar(10)  ,
    @Price2  varchar(10)  ,
    @StickerPrice  varchar(10)  ,
    @TotInvAmt  varchar(10)  ,
    @OptRetail  varchar(max)  ,
    @OptInvAmt  varchar(10)  ,
    @OptCost  varchar(10)  ,
    @Options  varchar(max)  ,
    @Category  varchar(max)  ,
    @Description  varchar(max)  ,
    @Engine  varchar(max)  ,
    @ModelType  varchar(max)  ,
    @FTCode  varchar(max)  ,
    @Wholesale  varchar(max)  ,
    @Retail  varchar(max)  ,
    @Draft  varchar(max)  ,
    @Inventoryid int;
    DECLARE Inventory_Cursor CURSOR FOR 
    SELECT * from [dbo].[FLATFILE_INVENTORY];
    OPEN Inventory_Cursor
    FETCH NEXT FROM Inventory_Cursor 
    INTO @FileType   ,
    @ACDealerID     ,
    @ClientDealerID     ,
    @DMSType     ,
    @StockNumber     ,
    @InventoryDate    ,
    @StockType    ,
    @DMSStatus     ,
    @InvoicePrice     ,
    @CostPack     ,
    @SalesCost     ,
    @HoldbackAmount     ,
    @ListPrice     ,
    @MSRP     ,
    @LotLocation     ,
    @TagLine     ,
    @Certification     ,
    @CertificationNumber     ,
    @VehicleVIN     ,
    @VehicleYear     ,
    @VehicleMake     ,
    @VehicleModel     ,
    @VehicleModelCode     ,
    @VehicleTrim     ,
    @VehicleSubTrimLevel     ,
    @Classification     ,
    @TypeCode    ,
    @VehicleMileage     ,
    @EngineCylinderCount     ,
    @TransmissionType     ,
    @VehicleExteriorColor     ,
    @VehicleInteriorColor     ,
    @CreatedDate    ,
    @LastModifiedDate    ,
    @ModifiedFlag     ,
    @InteriorColorCode     ,
    @ExteriorColorCode     ,
    @PackageCode     ,
    @CodedCost     ,
    @Air    ,
    @OrderType     ,
    @AgeDays     ,
    @OutstandingRO     ,
    @DlrAccessoryRetail     ,
    @DlrAccessoryCost     ,
    @DlrAccessoryDesc     ,
    @ModelDesc     ,
    @Memo1 ,
    @Memo2     ,
    @Weight     ,
    @FloorPlan     ,
    @Purchaser     ,
    @PurchasedFrom     ,
    @InternetPrice     ,
    @InventoryAcctDollar     ,
    @VehicleType     ,
    @DealerAccessoryCode     ,
    @AllInventoryAcctDollar     ,
    @BestPrice     ,
    @InStock     ,
    @AccountingMake     ,
    @GasDiesel     ,
    @BookValue     ,
    @FactoryAccessoryDescription     ,
    @TotalReturn     ,
    @TotalCost     ,
    @SS     ,
    @VehicleBody     ,
    @StandardEquipment     ,
    @Account     ,
    @CalculatedPrice     ,
    @OriginalCost     ,
    @AccessoryCore     ,
    @OtherDollar     ,
    @PrimaryBookValue     ,
    @AmountDue     ,
    @LicenseFee     ,
    @ICompany     ,
    @InvenAcct     ,
    @Field23     ,
    @Field24     ,
    @SalesCode     ,
    @BaseRetail     ,
    @BaseInvAmt     ,
    @CommPrice     ,
    @Price1     ,
    @Price2     ,
    @StickerPrice     ,
    @TotInvAmt     ,
    @OptRetail     ,
    @OptInvAmt     ,
    @OptCost     ,
    @Options     ,
    @Category     ,
    @Description     ,
    @Engine     ,
    @ModelType     ,
    @FTCode     ,
    @Wholesale     ,
    @Retail     ,
    @Draft     ;
    WHILE @@FETCH_STATUS = 0
    BEGIN
        PRINT @VehicleVIN    ;
    -- ****************** insert into Inventory Table ***********
    INSERT INTO INVENTORY 
    IconicDealerID,
    StockNumber,
    DMSType,
    InventoryDate
    VALUES (@ClientDealerID,@StockNumber,@DMSType,@InventoryDate);
    set @Inventoryid = scope_identity();
    PRINT @Inventoryid;
    --Insert into Inventory_Details Table
    INSERT INTO [INVENTORY_DETAILS]
    InventoryID,
    StockType,
    DMSStatus,
    LotLocation,
    TagLine,
    Certification,
    CertificationNumber,
    CreatedDate,
    LastModifiedDate,
    ModifiedFlag,
    PackageCode,
    OrderType,
    AgeDays,
    OutstandingRO,
    Memo1,
    Memo2,
    Purchaser,
    PurchasedFrom,
    DealerAccessoryCode,
    InStock,
    AccountingMake,
    SS,
    Account,
    AccessoryCore,
    ICompany,
    InvenAcct,
    Field23,
    Field24,
    SalesCode,
    Draft,
    FTCode
    VALUES (
    @InventoryID,
    @StockType,
    @DMSStatus,
    @LotLocation,
    @TagLine,
    @Certification,
    @CertificationNumber,
    @CreatedDate,
    @LastModifiedDate,
    @ModifiedFlag,
    @PackageCode,
    @OrderType,
    @AgeDays,
    @OutstandingRO,
    @Memo1,
    @Memo2,
    @Purchaser,
    @PurchasedFrom,
    @DealerAccessoryCode,
    @InStock,
    @AccountingMake,
    @SS,
    @Account,
    @AccessoryCore,
    @ICompany,
    @InvenAcct,
    @Field23,
    @Field24,
    @SalesCode,
    @Draft,
    @FTCode
    --Insert into Inventory_Amount Table
    INSERT INTO [dbo].[INVENTORY_AMOUNT]
    InventoryID,
    AllInventoryAcctDollar,
    OtherDollar,
    PrimaryBookValue,
    AmountDue,
    LicenseFee,
    CalculatedPrice,
    OriginalCost,
    BookValue,
    TotalReturn,
    TotalCost,
    DlrAccessoryRetail,
    DlrAccessoryCost,
    DlrAccessoryDesc,
    InternetPrice,
    InventoryAcctDollar,
    BestPrice,
    Weight,
    FloorPlan,
    CodedCost,
    InvoicePrice,
    CostPack,
    SalesCost,
    HoldbackAmount,
    ListPrice,
    MSRP,
    BaseRetail,
    BaseInvAmt,
    CommPrice,
    Price1,
    Price2,
    StickerPrice,
    TotInvAmt,
    OptRetail,
    OptInvAmt,
    OptCost,
    Wholesale,
    Retail
    VALUES (
    @InventoryID,
    @AllInventoryAcctDollar,
    @OtherDollar,
    @PrimaryBookValue,
    @AmountDue,
    @LicenseFee,
    @CalculatedPrice,
    @OriginalCost,
    @BookValue,
    @TotalReturn,
    @TotalCost,
    @DlrAccessoryRetail,
    @DlrAccessoryCost,
    @DlrAccessoryDesc,
    @InternetPrice,
    @InventoryAcctDollar,
    @BestPrice,
    @Weight,
    @FloorPlan,
    @CodedCost,
    @InvoicePrice,
    @CostPack,
    @SalesCost,
    @HoldbackAmount,
    @ListPrice,
    @MSRP,
    @BaseRetail,
    @BaseInvAmt,
    @CommPrice,
    @Price1,
    @Price2,
    @StickerPrice,
    @TotInvAmt,
    @OptRetail,
    @OptInvAmt,
    @OptCost,
    @Wholesale,
    @Retail
    --Insert into Inventory_Vehicle Table
    INSERT INTO [dbo].[INVENTORY_VEHICLE]
    InventoryID,
    InteriorColorCode,
    ExteriorColorCode,
    Air,
    ModelDesc,
    VehicleType,
    VehicleVIN,
    VehicleYear,
    VehicleMake,
    VehicleModel,
    VehicleModelCode,
    VehicleTrim,
    VehicleSubTrimLevel,
    Classification,
    TypeCode,
    VehicleMileage
    VALUES (
    @InventoryID,
    @InteriorColorCode,
    @ExteriorColorCode,
    @Air,
    @ModelDesc,
    @VehicleType,
    @VehicleVIN,
    @VehicleYear,
    @VehicleMake,
    @VehicleModel,
    @VehicleModelCode,
    @VehicleTrim,
    @VehicleSubTrimLevel,
    @Classification,
    @TypeCode,
    @VehicleMileage
    -- Move cursor to Next record 
        FETCH NEXT FROM Inventory_Cursor 
    INTO @FileType   ,
    @ACDealerID     ,
    @ClientDealerID     ,
    @DMSType     ,
    @StockNumber     ,
    @InventoryDate    ,
    @StockType    ,
    @DMSStatus     ,
    @InvoicePrice     ,
    @CostPack     ,
    @SalesCost     ,
    @HoldbackAmount     ,
    @ListPrice     ,
    @MSRP     ,
    @LotLocation     ,
    @TagLine     ,
    @Certification     ,
    @CertificationNumber     ,
    @VehicleVIN     ,
    @VehicleYear     ,
    @VehicleMake     ,
    @VehicleModel     ,
    @VehicleModelCode     ,
    @VehicleTrim     ,
    @VehicleSubTrimLevel     ,
    @Classification     ,
    @TypeCode    ,
    @VehicleMileage     ,
    @EngineCylinderCount     ,
    @TransmissionType     ,
    @VehicleExteriorColor     ,
    @VehicleInteriorColor     ,
    @CreatedDate    ,
    @LastModifiedDate    ,
    @ModifiedFlag     ,
    @InteriorColorCode     ,
    @ExteriorColorCode     ,
    @PackageCode     ,
    @CodedCost     ,
    @Air    ,
    @OrderType     ,
    @AgeDays     ,
    @OutstandingRO     ,
    @DlrAccessoryRetail     ,
    @DlrAccessoryCost     ,
    @DlrAccessoryDesc     ,
    @ModelDesc     ,
    @Memo1 ,
    @Memo2     ,
    @Weight     ,
    @FloorPlan     ,
    @Purchaser     ,
    @PurchasedFrom     ,
    @InternetPrice     ,
    @InventoryAcctDollar     ,
    @VehicleType     ,
    @DealerAccessoryCode     ,
    @AllInventoryAcctDollar     ,
    @BestPrice     ,
    @InStock     ,
    @AccountingMake     ,
    @GasDiesel     ,
    @BookValue     ,
    @FactoryAccessoryDescription     ,
    @TotalReturn     ,
    @TotalCost     ,
    @SS     ,
    @VehicleBody     ,
    @StandardEquipment     ,
    @Account     ,
    @CalculatedPrice     ,
    @OriginalCost     ,
    @AccessoryCore     ,
    @OtherDollar     ,
    @PrimaryBookValue     ,
    @AmountDue     ,
    @LicenseFee     ,
    @ICompany     ,
    @InvenAcct     ,
    @Field23     ,
    @Field24     ,
    @SalesCode     ,
    @BaseRetail     ,
    @BaseInvAmt     ,
    @CommPrice     ,
    @Price1     ,
    @Price2     ,
    @StickerPrice     ,
    @TotInvAmt     ,
    @OptRetail     ,
    @OptInvAmt     ,
    @OptCost     ,
    @Options     ,
    @Category     ,
    @Description     ,
    @Engine     ,
    @ModelType     ,
    @FTCode     ,
    @Wholesale     ,
    @Retail     ,
    @Draft     ;
    END 
    CLOSE Inventory_Cursor;
    DEALLOCATE Inventory_Cursor;
    GO
    SET ANSI_PADDING OFF
    GO
    Arunraj Kumar

  • ALV Grid default values for new rows added with Add/Insert buttons

    Hi!
    Help, please,  to find a way how to set default values for new rows added with Add/Insert buttons in
    ALV Grid.

    I have found salution:
    ALV Grid u2013 Insert row function
    Sometimes we need to assign some default values when we create a new row in a grid using standard ALV Append row button. In our scenario we will see how to assign default values to Airline Code (CARRID), Flight Connection Number (CONNID) and Flight date (FLDATE) when a new row is created. To do that we need to handle DATA_CHANGED event in the program like mentioned below.
    Definition of a class:
    Code:
          CLASS lcl_event_receiver DEFINITION
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
    METHODS:
         handle_data_changed
         FOR EVENT data_changed OF cl_gui_alv_grid
         IMPORTING er_data_changed
                           e_ucomm.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    Implementation of a class:
    Code:
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
      METHOD HANDLE_DATA_CHANGED.
        DATA: dl_ins_row TYPE lvc_s_moce.   " Insert Row
          FIELD-SYMBOLS: <fs> TYPE table.    " Output table
    Loop at the inserted rows table and assign default values
        LOOP AT er_data_changed->mt_inserted_rows INTO dl_ins_row.
          ASSIGN er_data_changed->mp_mod_rows->* TO <fs>.
          loop at <fs> into ls_outtab.
            ls_outtab-carrid  = 'LH'.
            ls_outtab-connid  = '400'.
            ls_outtab-fldate  = sy-datum.
            MODIFY <fs> FROM ls_outtab INDEX sy-tabix.
          endloop.
        endloop.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    Register the events to trigger DATA_CHANGED event when a new row is created.
    Code:
        CALL METHOD OBJ_GRID->REGISTER_EDIT_EVENT
          EXPORTING
            I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
        CALL METHOD OBJ_GRID->REGISTER_EDIT_EVENT
          EXPORTING
            I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.

  • Merge inserting duplicate rows

    Hi,
    I first check if a particular dept_no exists in the table, if not insert into the table. I am getting duplicate rows inserted.
    This is the table data before Merge.
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000This is the table data after Merge.
    3 rows merged.
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000
             4 Ram                  Bharad                       30       2000
             4 Ram                  Bharad                       30       2000
             4 Ram                  Bharad                       30       2000
    6 rows selected.This is the code to merge
    MERGE INTO customer c
    USING ( SELECT cust_id,
                   first_name,
                   last_name,
                   dept_no,
                   salary
            FROM customer ) e
    ON ( c.dept_no = 30 )
    WHEN MATCHED THEN
        UPDATE SET
               c.cust_id    = 4,
               c.first_name = 'Ram',
               c.last_name  = 'Bharad',
               c.salary     = 2000
    WHEN NOT MATCHED THEN
        INSERT
        (c.cust_id,c.first_name, c.last_name,c.dept_no,c.salary)
        VALUES
        (4,'Ram','Bharad',30,2000);Shouldn't the above code insert once, and update twice?
    Thanks

    You have done it wrong...
    Try like this
    SQL> create table customer(cust_id number,first_name varchar2(20), last_name varchar2(20), dept_no number, salary number)
      2  /
    Table created.
    SQL> insert into customer
      2  select 1, 'Dan','Morgan',10,100000 from dual
      3  union all
      4  select 2, 'Jack','Cline',20,100000 from dual
      5  union all
      6  select 3, 'Helen','Lofstrom',20,50000 from dual
      7  /
    3 rows created.
    SQL> commit
      2  /
    Commit complete.
    SQL> select * from customer
      2  /
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000
    SQL> MERGE INTO customer c
      2  USING ( SELECT 4 cust_id,
      3                 'Ram' first_name,
      4                 'Bharad' last_name,
      5                 30 dept_no,
      6                 2000 salary
      7          FROM dual ) e
      8  ON ( c.dept_no = e.dept_no )
      9  WHEN MATCHED THEN
    10      UPDATE SET
    11             c.cust_id    = e.cust_id,
    12             c.first_name = e.first_name,
    13             c.last_name  = e.last_name,
    14             c.salary     = e.salary
    15  WHEN NOT MATCHED THEN
    16      INSERT
    17      (c.cust_id,c.first_name, c.last_name,c.dept_no,c.salary)
    18      VALUES
    19      (e.cust_id,e.first_name, e.last_name,e.dept_no,e.salary);
    1 row merged.
    SQL> select * from customer
      2  /
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000
             4 Ram                  Bharad                       30       2000but beware of the fact that you are joining based on dept_no so multiple rows can get updated with same cust_id. see below.
    SQL> rollback
      2  /
    Rollback complete.
    SQL>  MERGE INTO customer c
      2   USING ( SELECT 4 cust_id,
      3             'Ram' first_name,
      4             'Bharad' last_name,
      5             20 dept_no,
      6             2000 salary
      7      FROM dual ) e
      8   ON ( c.dept_no = e.dept_no )
      9   WHEN MATCHED THEN
    10       UPDATE SET
    11         c.cust_id    = e.cust_id,
    12         c.first_name = e.first_name,
    13         c.last_name  = e.last_name,
    14         c.salary     = e.salary
    15   WHEN NOT MATCHED THEN
    16       INSERT
    17       (c.cust_id,c.first_name, c.last_name,c.dept_no,c.salary)
    18       VALUES
    19       (e.cust_id,e.first_name, e.last_name,e.dept_no,e.salary);
    2 rows merged.
    SQL> select * from customer
      2  /
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             4 Ram                  Bharad                       20       2000
             4 Ram                  Bharad                       20       2000Thanks,
    Karthick.

  • Generate a surregate key only when insert a new row - (SCD1)

    Hi all,
    I&acute;m starting with OWB (10gR2) and I'm creating a simple template dimension with SDC type 1 with one source, one target and a sequence do generate the surrogate key.
    The main properties configurations are:
    - Target property: Loading type = INSERT/UPDATE.
    - Only match the natural key between source and target.
    - Only use the sequence.nextval when inserting a new row.
    - Mapping: Set based.
    The generated code was something like this:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(SQ_DIM_DEFAULT.NEXTVAL,SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    Ok, it works fine! But the merge statement generates a new SK for each merged row even if the action is update! What I want is a new SK only when the process inserts a new row. Hard-coding, I possible solve this problem creating a function to return the nextval from a sequence and put it on the insert clause like this:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(FN_SQC_NEXTVAL('SQ_DIM_DEFAULT'),SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    Hard-coded it works fine as I need and that&acute;s the point that I want to know:
    It&acute;s possible perform this solution using OWB?
    I tried to use Constants but this solution doesn&acute;t work then I tried an expression calling my sequence.nextval function but the result was:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING (SELECT FN_SQC_NEXTVAL('SQ_DIM_DEFAULT') AS SK_DEFAULT_0,NATURALKEY,NAME FROM SCR_TABLE) AS SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(SK_DEFAULT_0,SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    It&acute;s the same of merge the row using the SEQUENCE.NEXTVAL direct.
    Does anyone have a workaround to solve this situation?

    Hi,
    Perhaps this comes a bit late but...
    Have you tried to change attribute properties in the mapping? For simple example you have a source table in sa-stage which have to fields: code (varchar2(2), natural key) and description (varchar2(50)). You want to map those fields to target table where you have 3 fields: id (NUMBER(10), surrogate id, nextval from sequence when new row inserted), code (as from the source, natural key, the field to determine if the coming row is new or one to be merged) and description as in source table. Fields and datatypes are just for an example.
    When you have source and target tables in your mapping (and fields mapped), drag the sequence operator to the mapping and map the nextval to target table's surrogate id field.
    - Change target table operator properties:
    * loading type = UPDATE/INSERT
    * Match by constraint = no constraint
    - Change target table attribute properties for:
    * surrogate id field: Load column when updating row = no; match column when updating row = no; load column when inserting row = yes
    * natural key field(s): Load column when updating row = no; match column when updating row = yes; load column when inserting row = yes
    * all the regular fields: Load column when updating row = yes; match column when updating row = no; load column when inserting row = yes
    - change the deleting rules as you want them to be
    - Validate your mapping. If the green light is shown, the settings in field properties are suitable for merge.
    Hope this is what you wanted to get. I think this kind of solution works fine. Trigger in the table that holds and where one inserts millions of rows sounds scary...
    Regards,
    jk
    Added text: sorry about false alarm. I think that was what you did. The solution above steals the nextvals from sequence. Perhaps no-native-english-reader should be more careful when reading questions ;-)
    Edited by: jkoski on 5.11.2008 1:30

  • Photoshop CC : Workspace Flashing Black When Inserting Guides & Completely Black When Adding Text

    I recently bought Photoshop CC (2 Days Ago) and shortly after installing I jumped onto Photoshop CC and started to set up the prefferences for my personal use and started to just do some basic stuff and see whats new in CC. when inserting Guides & adding Text the workspace started to flash/stay BLACK. I don't know whats going on but my specs are better than the minimum requirements? Any idea whats going on? Operating System : Windows 8.1

    Have a look through this step by step guide.
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
    It's coming up 1am here, so I am calling it a night.

  • How to eliminate inserting  Duplicate rows into database using JDBC Adapter

    File->Xi->JDBC
    In above Scenario if the file has two rows their values are identical, then how can we eliminated inserting  Duplicate rows into database using JDBC Adapter

    Database is a consumer of a SERVICE (SOA!!!!!!).
    Database plays a business system role here!!!!
    Mapping is part of an ESB service
    Adaptor is a technology adapted to ESB framework to support specific protocol.
    ESB accomplish ESB duties such as transformation, translation, routing. Routing use a protocol accepted by the consumer. In a JDBC consumer it is JDBC protocol and hence it a JDBC adaptor.
    There is clear separation on responsibilities among business system and ESB. ESB do not participate in business decision or try to get into business system data layer.
    So who ever are asking people to check duplicate check as part of mapping (an ESB service) may not understand integration practice.
    Please use an adaptor module which will execute the duplicate check with business system in a plug and play approach and separate that from ESB service so that people can build integration using AGILE approach.
    Thanks

  • I thought as a consumer, Apple works for us.  Had I known what I'd lose by upgrading, I would have thought twice!!!  I want Front Row BACK!!! also what is this new playlist that was auto added when I upgraded?  It's called iTunes  Artwork screen?

    I thought as a consumer, Apple works for us.  Had I known what I'd lose by upgrading, I would have thought twice!!!  I want Front Row BACK!!! also what is this new playlist that was auto added when I upgraded?  It's called iTunes  Artwork screen? 

    Think the iTunes artwork playlist is for a new screensave they put in where if you click the album artwork it plays the song.

  • Preventing duplicate rows insertion

    suppose i have a table with 2 columns
    no constraints are there
    then how i will prevent duplicate rows insertion using triggers.

    but i tried to solve the poster's requirement.yes, but the trigger does not solve it.
    The example you posted above, try this:
    do the first insert in your first sql*plus session, and then without committing, open another sql*plus session and do the second insert.
    Do you see an error?
    SQL> create table is_dup(x number, y varchar2(10));
    Table created.
    SQL> CREATE OR REPLACE TRIGGER chk
      2      BEFORE INSERT ON is_dup
      3      FOR EACH ROW
      4  BEGIN
      5      FOR i IN (SELECT * FROM is_dup)
      6      LOOP
      7          IF (:NEW.x = i.x) AND
      8             (:NEW.y = i.y)
      9          THEN
    10              raise_application_error(-20005, 'Record already exist...');
    11          END IF;
    12      END LOOP;
    13  END;
    14  /
    Trigger created.
    SQL> insert into is_dup values(123,'MYNAME');
    1 row created.
    SQL>
    SQL> $sqlplus /
    SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 23 10:17:07 2006
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> insert into is_dup values(123,'MYNAME');
    1 row created.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from is_dup ;
             X Y
           123 MYNAME
           123 MYNAME
    SQL> commit ;
    Commit complete.
    SQL> select * from is_dup ;
             X Y
           123 MYNAME
           123 MYNAME
    SQL>

  • Update/Insert Duplicate Rows

    Hi I am loading a target table [empty] for the first time. I am using update/insert strategy. however, it's only inserting. not updating inserted rows.

    In a single mapping and on an empty table you can only insert rows. The Insert/Update strategy will update rows if the matching criteria you have used satisfies on an existing set of rows prior to your running the mapping. In other words you cannot expect OWB to update rows which it has inserted in the same statement !...
    You can try Row Based mode and put an order by clause before inserting into the target table and check to see if the update happens.
    Regards
    -AP

  • Duplicate rows in AdvancedDataGrid when pushing updates via custom Assembler?

    We are trying to use LCDS transactions to dynamically push updates from a server side application via custom Assembler to AdvancedDataGrid.  Latter is using fill result ArrayList as its data source.
    Unfortunately we haven't been fully successful thus far. Grid shows fine initial snapsot delivered by fill but subsequent record updates result in a duplicate rows shown in a grid. 
    We are using Flex 3, SDK 3.5 and LCDS ES 2.6.1.
    Here is the relevant code in our custom assembler to do the update push:
    _results.add(dataUpdate); // _results is the ArrayList object returned with data on the original fill
    DataServiceTransaction dtx = DataServiceTransaction.begin("FOO", false);
    dtx.addItemToFill(_assemblerId, _currentParams, _results.size()-1,dataUpdate);
    dtx.commit();
    // we see this method gets called as result of the code above
    public Object getItem(Map identity) {
          Object item = null;
          String id = identity.get("ID").toString();
          for (LinkedHashMap<String,Object> itemMap : _results) {
          if (itemMap.get("ID").equals(id)) {
                item = itemMap;
           break;
          return item;
    And finally here is the destination configuration for the assembler in the data-management-config.xml file:
    <destination id="updates">
      <properties>    
             <source>UpdatesAssembler</source>
            <scope>session</scope>
      <auto-sync-enabled>false</auto-sync-enabled>
      <metadata>
                     <identity property="ID"/>
      </metadata>
      <network>
                     <paging enabled="false"/>
      </network>
    </properties>
    </destination>
    And naturally, we bind the datagrid dataProvider to the array collection returned by the original fill call.
    As stated above, this solution results in two rows of the same data appearing in datagrid for every updated pushed by the assembler.
    Can you please advise what are we doing wrong.
    Thanks!

    What events are coming back to the client?
    If you add an event listener to the dataService object in ActionScript, you can see what events are coming in.
        dataService.addEventListener(MessageEvent.RESULT, resultHandler);
    This might help diagnose it.

  • Lookup transformation to avoid duplicate rows? - SSIS 2005

    Hi,
    I'm maintaning a SSIS 2005 pkg. I need to read a flat file to write on a SQL Server table, avoiding duplicates.
    I can have duplicates rows into the flat file to import and I need to prevent the insert of any rows already existing in the SQL Server table.
    So, I think to use a lookup transformation. I've created a flat file source, then I connect it to a lookup transformation and inside it I've specified as the reference table the SQL Server destination table. Then, I've checked the available lookup columns
    each adding as a new column: but the lookup task has arised an error and so I've specified as lookup operation the replacement. For each unmatching I need to write on the SQL Server table (the reference table in the lookup). For the lookup output error I've
    indicate to ignore failure. Other steps?
    However, when I run the pkg then inside the SQL Server destination table I can see only NULL values, but I want to see the rows don't already present in the table.
    Any suggests to me, please? Thanks

    Hi,
    I'm using SSIS 2005 as reported in the title of the post.
    I could have duplicates inside the source file and the existing table could haven't any rows.
    Thanks
    If you dont have any rows in existing table, then they will go through Error output in lookup task. For duplicates, lookup task will find matches and will go through lookup match output
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for