Conditional Insert within Merge???

can we use conditional insert within the merge statement????
thanks a lot..
nantha

NanthaKumarAR wrote:
is there is any possible way to do so????
thanks a alot ....
nanthaHmmm let's look at the conversation so far...
You: "is this possible?????"
Me: "No."
You: "is there is any possible way to do so????"
I'm now wondering which part of "No" you failed to understand.
You cannot perform multiple/conditional inserts within a MERGE statement. The purpose of a MERGE statement is to take data and MERGE it into a single table.
The only messy way I can think of would be to merge into an intermediate table with triggers on it, that takes the merged data and splits it out into the seperate tables. Messy and not likely the best solution to the initial problem, which would probably be better solved by avoiding the use of MERGE in the first place (though we don't know what problem you are actually trying to solve).

Similar Messages

  • MERGE w/ conditional Insert clause

    Hi--
    Sum Up:Is it possible to run Merge syntax with update and a conditional Insert clauses ?
    Question Details
    Have a base table Emp and staging table New_Emp with a common identifier Emp_id.
    The ideal would be to merge the 2 tables and update Emp using New_Emp values and
    insert only some new emp, not all records.
    Any ideas ? Thks
    Lamine

    Absolutely. See the docs. Use the WHEN and WHERE clauses.
    Tom Best

  • Conditional Insert

    Hi,
    Is it possible to do a conditional insert? e.g.
    IF :P2_NAME != (SELECT name from hk.appname where name = :P2_NAME) then
    INSERT....
    END IF;So if the value of :P2_NAME doesn't exist within the table then it will be inserted...its to be an addition to a currently existing APEX process (checks that field values aren't null then enters a record into a different table than hk.appname).
    Thanks for any help.
    Mike

    Dird wrote:
    PLS-00405: subquery not allowed in this context As I said:
    IF :P6_NEW_PROJ IS NOT NULL THEN
    proj := lower(:P6_NEW_PROJ);
    ELSE
    proj := :P6_PROJECT;
    END IF;
    insert into hkadm.applic@XXX (appl_name) select proj from dual
    where 0 = (select count(*) from hkadm.applic@XXX where appl_name = proj and rownum = 1);SY.

  • Implementing Conditional Insert

    I use tips in the article "Implementing Conditional Insert, Update, and Delete Allows for View Objects" from "Steve Muench's Radio Weblog".
    At the start all it's ok, but I found this problem:
    1. I have two views (V1 and V2) over the same entity (E1)
    2. V1 permit insert, delete, update, and select.
    3. V2 overwrite method create and don't allow insert.
    4. If you use V1 and try to insert a record all go ok.
    5. If you use V2 and try to insert a record get an exception "It's not allow insert into V2", It's Ok.
    6. If you use V1 again and try to insert a record you get an exception, that say "It's not allow insert into V2".
    I'm investigate the case, and found that when you insert a record in E1 throw V1, the framework (BC4) try to create the record in the views that are instantiated over the entity E1, for this call method "create" on views.
    Do you know some workaround ?
    thank in advice...

    Hi, again, I have question about this...
    I post it in the forum...
    If I use "isAssociationConsistent()" I have to know all views that depend of same entity, and its privileges. I have problem with that because if I add a view a have to remember to put this in the code.
    I need to confirm: is return of method "this.getEntity(0).isInCache()" true when record was inserting in other entity ?
    May I modify your sample like this:
    public class CustomViewRowImpl extends ViewRowImpl {
    protected void create(AttributeList nvp) {
    if ( this.getEntity(0).isInCache() || getVO().isInsertAllowed()) {
    super.create(nvp);
    else {
    throw new JboException("Insert not allowed in this view");
    thank a lot

  • Conditional insert in plsql

    Hi friends,
    I am a beginner in Oracle PLSQL. I need to insert a row into a table based on a condition. The condition is to check if the value is already there in another table.
    i.e, If the username is already present in the users table then the username should not be added to username table. I have written a stored procedure to insert into the username table but need i do not know how to check for the condition.
    Could you please let me know how to get this. I tried a lot but getting compilation errors.
    Regards,
    Padeep

    Use Control Statements
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/controlstatements.htm
    Such as: IF-THEN-ELSE or CASE
    That documentation is for 11.2. Your Oracle version may be different, but since IF statements have been around for a long time, this will do.
    Alternatively, consider a unique index on the field.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17120/indexes003.htm#ADMIN11724
    Or even consider using a MERGE statement:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_9016.htm#SQLRF01606

  • To avoid duplicates while inserting using MERGE command

    I have a merge query as below
    merge into ord_act A
    using (select col1,col2... from table,table2,table3 where condition1 and condition2 ...) S on (conditions..)
    WHEN NOT MATCHED THEN
    INSERT (A.col1,A.col2,..A.coln) values(S.col1,S.col2,..s.coln) WHEN MATCHED THEN UPDATE
    SET A.EVT_STAT_CD = S.v_evt_stat_cd,
    A.NAME = S.v_name,
    A.SUBTYPE_CD = S.v_subtype_cd
    commit;
    I don't want duplicates to be inserted into the ord_act table if the condition is not matched ? Please could you suggest on this
    thanks

    Then you should change USING clause query to produce distinct rows.
    SY.

  • Insert/update - merge  apex items

    hello =)
    i want to insert data into a table and if the table has already the "List_id" i want to update values:
    begin
    FOR i IN 1..APEX_APPLICATION.G_F01.COUNT LOOP
    MERGE INTO list_values
    USING dual
    ON (list_values.list_id = to_number(APEX_APPLICATION.G_F02(i))
    WHEN MATCHED THEN
    UPDATE
    SET
    list_values.product_fk=:P900_PRODUCT_NAME,
    ist_values.attribute=APEX_APPLICATION.G_F04(i),
    list_values.value=APEX_APPLICATION.G_F05(i)
    WHEN NOT MATCHED THEN
    INSERT
    list_values.product_fk,list_values.attribute,list_values.value
    VALUES
    *:P900_PRODUCT_NAME,APEX_APPLICATION.G_F04(i),APEX_APPLICATION.G_F05(i)*
    end loop;
    end;
    got a lot of sql errors...
    +1+ error has occurred
    ORA-06550:line 6, column 65: PL/SQL: ORA-00907: missing right parenthesis ORA-06550: line 4, column 1: PL/SQL: SQL Statement ignored
    Maybe someone can help me with the syntax of the merge statement or maybe merge doesn't work in this case. because of the apex_items.
    also got seperated insert/update process. they work perfect, if i use the processes singly:
    Begin
    FOR i IN 1..APEX_APPLICATION.G_F01.COUNT LOOP
    insert into List_values (product_fk,attribute,value)
    values (:P900_PRODUCT_NAME,APEX_APPLICATION.G_F04(i),APEX_APPLICATION.G_F05(i));
    END LOOP;
    end;
    begin
    FOR i IN 1..APEX_APPLICATION.G_F01.COUNT LOOP
    update List_values
    set
    product_fk=:P900_PRODUCT_NAME,
    attribute=APEX_APPLICATION.G_F04(i),
    value=APEX_APPLICATION.G_F05(i)
    where list_id=to_number(APEX_APPLICATION.G_F02(i));
    END LOOP;
    end;
    Maybe someone can help me to combine them.
    Thank u =)

    You were missing a right parenthesis at the end of line 7.
    BEGIN
       FOR i IN 1 .. APEX_APPLICATION.g_f01.COUNT
       LOOP
          MERGE INTO LIST_VALUES
               USING DUAL
                  ON (LIST_VALUES.list_id =
                         TO_NUMBER (APEX_APPLICATION.g_f02 (i)))
          WHEN MATCHED
          THEN
             UPDATE SET
                LIST_VALUES.product_fk = :p900_product_name,
                ist_values.attribute = APEX_APPLICATION.g_f04 (i),
                LIST_VALUES.VALUE = APEX_APPLICATION.g_f05 (i)
          WHEN NOT MATCHED
          THEN
             INSERT     (LIST_VALUES.product_fk,
                         LIST_VALUES.attribute,
                         LIST_VALUES.VALUE)
                 VALUES (
                           :p900_product_name,
                           APEX_APPLICATION.g_f04 (i),
                           APEX_APPLICATION.g_f05 (i));
       END LOOP;
    END;Jeff

  • Conditionally inserting tiles

    Hello All,
    I am using tiles with JSF. In my jsf page, i have the below logic but still the tiles get inserted...
    <% if(false){ %>
    <tiles:insert definition="NonMember" flush="false"/>
    <% } %>
    I am not sure whats happening.. does anyone know whats happening here...
    Basically,i want to check a condition and if the condition is false, i dont want to insert the tiles..

    Make sure nonMember definition is accessible via the jsp page:
    <f:verbatim>
    <%
    String nonMember = ...
    if(false)
    %>
    <tiles:insert name="<%=nonMember%>" flush="false" />
    <%
    %>
    </f:verbatim>
    Hope this may help.
    BaTien
    DBGROUPS

  • Rows updated and inserted by  MERGE

    Hi,
    Is there any way I can come to know, How many rows are updated and inserted using a MERGE statement.
    Thanks in advance

    Something like this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>
    satyaki>desc aud_emp;
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    AUDIT_TMP                                          TIMESTAMP(6)
    AUDIT_IP_ADDR                                      VARCHAR2(15)
    OPR_DESC                                           VARCHAR2(30)
    USER_NM                                            VARCHAR2(40)
    REMARKS                                            VARCHAR2(200)
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
    no rows selected
    Elapsed: 00:00:00.04
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>select * from e_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81    3718.75                    20
          7782 CLARK      MANAGER         7839 09-JUN-81     3062.5                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82      11700                    10
    7 rows selected.
    Elapsed: 00:00:00.07
    satyaki>CREATE OR REPLACE TRIGGER trg_aud
    before insert or update or delete on e_emp
    for each row
    declare
         S_IP_ADDR    varchar2(30);
         str          varchar2(320);
         s_empno      varchar2(40);
         s_ename      varchar2(40);
         s_job        varchar2(40);
         s_mgr        varchar2(40);
         s_hrdate     varchar2(40);
         s_sal        varchar2(40);
         s_comm       varchar2(40);
         s_deptno     varchar2(40);
    begin
         SELECT SYS_CONTEXT('USERENV','IP_ADDRESS')
         into S_IP_ADDR
         from dual;
         str:= null;
         if inserting then
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'INSERT',
                                        USER,
                                        NULL);
         elsif updating then
           if :old.empno <> :new.empno then
              s_empno := 'Employee No: '||:old.empno;
           elsif :old.ename <> :new.ename then
              s_ename := 'Employee Name: '||:old.ename;
           elsif :old.job <> :new.job then
              s_job := 'Job: '||:old.job;
           elsif :old.mgr <> :new.mgr then
              s_mgr := 'Mgr: '||:old.mgr;
           elsif :old.hiredate <> :new.hiredate then
              s_hrdate := 'Hire Date: '||:old.hiredate;
           elsif :old.sal <> :new.sal then
              s_sal := 'Salary: '||:old.sal;
           elsif :old.comm <> :new.comm then
              s_comm := 'Commission: '||:old.comm;
           elsif :old.deptno <> :new.deptno then
              s_deptno := 'Department No: '||:old.deptno;
           end if;
           str:= 'Updated Records Details -> '||s_empno||' '||s_ename||' '||s_job||' '||s_mgr||' '||s_hrdate||' '||s_sal||' '||s_comm||' '||s_deptno;
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'UPDATE',
                                        USER,
                                        str);
         elsif deleting then
             insert into aud_emp values(:old.empno,
                                        :old.ename,
                                        :old.job,
                                        :old.mgr,
                                        :old.hiredate,
                                        :old.sal,
                                        :old.comm,
                                        :old.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'DELETE',
                                        USER,
                                        'Old Records before deletion');
         end if;
    exception
        when others then
          raise_application_error(-20501,'Contact With Your Admin....');
    end;
    Trigger Created.
    Elapsed: 00:00:00.09
    satyaki>ed
    Wrote file afiedt.buf
      1  merge into e_emp o
      2     using emp n
      3     on ( o.empno = n.empno)
      4     when matched then
      5       update set o.ename = n.ename,
      6                  o.job   = n.job,
      7                  o.mgr   = n.mgr,
      8                  o.hiredate = n.hiredate,
      9                  o.sal = n.sal,
    10                  o.comm = n.comm,
    11                  o.deptno = n.deptno
    12     when not matched then
    13       insert( o.empno,
    14               o.ename,
    15               o.job,
    16               o.mgr,
    17               o.hiredate,
    18               o.sal,
    19               o.comm,
    20               o.deptno)
    21       values( n.empno,
    22               n.ename,
    23               n.job,
    24               n.mgr,
    25               n.hiredate,
    26               n.sal,
    27               n.comm,
    28*              n.deptno)
    satyaki>/
    13 rows merged.
    Elapsed: 00:00:03.95
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.07
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20 31-DEC-08 10.54.06.667000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3718.75
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10 31-DEC-08 10.54.06.686000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3062.5
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20 31-DEC-08 10.54.06.687000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7839 KING       PRESIDENT            17-NOV-81       7000                    10 31-DEC-08 10.54.06.697000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 5000
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20 31-DEC-08 10.54.06.698000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20 31-DEC-08 10.54.06.699000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30 31-DEC-08 10.54.06.720000 PM                                                10.23.99.77     INSERT                         SCOTT
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10 31-DEC-08 10.54.07.059000 PM                                                10.23.99.77     INSERT                         SCOTT
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30 31-DEC-08 10.54.07.062000 PM                                                10.23.99.77     INSERT                         SCOTT
    13 rows selected.
    Elapsed: 00:00:00.22
    satyaki>
    satyaki>set lin 80Hope this will help you.
    Regards.
    Satyaki De.

  • Subquery within MERGE?

    Hello,
    I'm having a bit of difficulty getting a MERGE command to work with a subquery as part of the imported data. Thoughts?
    -- Clean up from prior run, if there was one
    DROP TABLE PARENT CASCADE CONSTRAINTS;
    DROP TABLE CHILD CASCADE CONSTRAINTS;
    DROP TABLE INPUT CASCADE CONSTRAINTS;
    DROP SEQUENCE ENTERPRISE_SEQ;
    --create objects for test
    CREATE TABLE PARENT(
    PARENT_ENTERPRISE_ID NUMBER(4, 0) NOT NULL,
    PARENT_SOURCE_NAME VARCHAR2(20) NOT NULL,
    PARENT_SOURCE_ID VARCHAR2(20) NOT NULL,
    PARENT_COMMENT VARCHAR2(25) NOT NULL,
    CONSTRAINT PARENT_PK PRIMARY KEY (PARENT_ENTERPRISE_ID),
    CONSTRAINT PARENT_AK UNIQUE (PARENT_SOURCE_NAME, PARENT_SOURCE_ID)
    CREATE SEQUENCE ENTERPRISE_SEQ;
    CREATE TABLE CHILD(
    PARENT_ENTERPRISE_ID NUMBER(4, 0) NOT NULL,
    CHILD_ENTERPRISE_ID NUMBER(4, 0) NOT NULL,
    CHILD_SOURCE_NAME VARCHAR2(20) NOT NULL,
    CHILD_SOURCE_ID VARCHAR2(20) NOT NULL,
    CHILD_COMMENT VARCHAR2(25) NOT NULL,
    CONSTRAINT CHILD_PK PRIMARY KEY (CHILD_ENTERPRISE_ID),
    CONSTRAINT CHILD_AK UNIQUE (CHILD_SOURCE_NAME, CHILD_SOURCE_ID)
    ALTER TABLE CHILD
    ADD CONSTRAINT CHILD_FK_PARENT
    FOREIGN KEY (PARENT_ENTERPRISE_ID)
    REFERENCES PARENT(PARENT_ENTERPRISE_ID)
    CREATE TABLE INPUT(
    INPUT_SOURCE_NAME VARCHAR2(10) NOT NULL,
    INPUT_SOURCE_ID VARCHAR2(20) NOT NULL,
    INPUT_RECORD_LEVEL VARCHAR2(10) NOT NULL,
    INPUT_COMMENT VARCHAR2(25) NOT NULL,
    INPUT_PARENT_RECORD_ID VARCHAR2(20) NULL,
    CONSTRAINT INPUT_PK PRIMARY KEY (INPUT_SOURCE_NAME, INPUT_SOURCE_ID)
    -- insert records into the table simulating external input
    -- note that the input table has two levels of records: Parent and Child
    insert into INPUT values ('Source A', '123', 'Parent', 'Input rec 1', null);
    insert into INPUT values ('Source A', '234', 'Parent', 'Input rec 2', null);
    insert into INPUT values ('Source A', '345', 'Child', 'Input rec 3', '123');
    insert into INPUT values ('Source A', '456', 'Child', 'Input rec 4', '123');
    -- Merge into Parent table
    -- This works just fine
    merge into PARENT P
    using (select INPUT_SOURCE_NAME,
    INPUT_SOURCE_ID,
    INPUT_COMMENT
    from INPUT
    where INPUT_RECORD_LEVEL = 'Parent'
    ) I
    on (I.INPUT_SOURCE_NAME = PARENT_SOURCE_NAME and
    I.INPUT_SOURCE_ID = PARENT_SOURCE_ID
    when matched then
    update set P.PARENT_COMMENT = I.INPUT_COMMENT
    when not matched then
    insert (P.PARENT_ENTERPRISE_ID,
    P.PARENT_SOURCE_NAME,
    P.PARENT_SOURCE_ID,
    P.PARENT_COMMENT
    values
    (ENTERPRISE_SEQ.NEXTVAL,
    I.INPUT_SOURCE_NAME,
    I.INPUT_SOURCE_ID,
    I.INPUT_COMMENT
    -- Merge into Child table
    -- This fails
    merge into CHILD C
    using (select INPUT_SOURCE_NAME,
    INPUT_SOURCE_ID,
    INPUT_COMMENT
    from INPUT
    where INPUT_RECORD_LEVEL = 'Child'
    ) I
    on (I.INPUT_SOURCE_NAME = C.CHILD_SOURCE_NAME
    and
    I.INPUT_SOURCE_ID = C.CHILD_SOURCE_ID
    when matched then
    update set C.CHILD_COMMENT = I.INPUT_COMMENT
    when not matched then
    insert (C.PARENT_ENTERPRISE_ID,
    C.CHILD_ENTERPRISE_ID,
    C.CHILD_SOURCE_NAME,
    C.CHILD_SOURCE_ID,
    C.CHILD_COMMENT
    values
    ((select PARENT_ENTERPRISE_ID
    from PARENT
    where PARENT_SOURCE_NAME = I.INPUT_SOURCE_NAME
    and PARENT_SOURCE_ID = I.INPUT_SOURCE_ID
    ENTERPRISE_SEQ.NEXTVAL,
    I.INPUT_SOURCE_NAME,
    I.INPUT_SOURCE_ID,
    I.INPUT_COMMENT
    select * from PARENT;
    select * from CHILD;

    ME_XE?merge into child c
      2  using
      3  (
      4     select
      5             i.input_source_name,
      6             i.input_source_id,
      7             i.input_comment,
      8             p.parent_enterprise_id
      9     from
    10             input   i,
    11             parent  p
    12     where i.input_record_level              = 'Child'
    13     and   i.input_source_name               = p.parent_source_name
    14     and   i.input_parent_record_id          = p.parent_source_id
    15  ) i
    16  on
    17  (
    18             i.input_source_name = c.child_source_name
    19     and     i.input_source_id   = c.child_source_id
    20  )
    21  when matched then
    22     update set c.child_comment = i.input_comment
    23  when not matched then
    24  insert
    25  (
    26     c.parent_enterprise_id,
    27     c.child_enterprise_id,
    28     c.child_source_name,
    29     c.child_source_id,
    30     c.child_comment
    31  )
    32  values
    33  (
    34     i.parent_enterprise_id,
    35     enterprise_seq.nextval,
    36     i.input_source_name,
    37     i.input_source_id,
    38     i.input_comment
    39  );
    2 rows merged.
    Elapsed: 00:00:00.01
    ME_XE?
    ME_XE?
    ME_XE?select * from parent;
    PARENT_ENTERPRISE_ID PARENT_SOURCE_NAME                                           PARENT_SOURCE_ID                                             PARENT_COMMENT
                       1 Source A                                                     123                                                          Input rec 1
                       2 Source A                                                     234                                                          Input rec 2
    2 rows selected.
    Elapsed: 00:00:00.00
    ME_XE?select * from child;
    PARENT_ENTERPRISE_ID CHILD_ENTERPRISE_ID CHILD_SOURCE_NAME                                            CHILD_SOURCE_ID                                              CHILD_COMMENT
                       1                   3 Source A                                                     345                                                          Input rec 3
                       1                   4 Source A                                                     456                                                          Input rec 4
    2 rows selected.
    Elapsed: 00:00:00.01
    ME_XE?

  • Conditional Insertion in table based on Field

    Hi all,
      I am having 3 text input fields in my page, Empno, Ename, Sal
      After inserting data in the fields, commission column has to be populate automatically, based on conditions.
      Conditions are : If the salary is less than 5000 the commission 500 has to be insert, salary is greater than 5000 commission 1000 has to be inserted.
    how can I achieve this, and where I have to implement the logic, please help me out.
    Thanks in Advance
    Jagadish

    Hi,
    You can apply PPR on salary field. Then catch the event and based on condition, set the value of commission field.
    Also, you can check this link for PPR:
    http://sushantsharmaa.blogspot.in/2012/12/11-ppr-partial-page-rendering-in-oaf.html
    --Sushant

  • Javascript popup insert within the body

    simple question im sure, i have a basic javascript
    <script type="text/javascript">
    <!--
    alert ("This is a JavaScript ALERT box.")
    // -->
    </script>
    however it needs to be inserted in the <head> however this is locked within the template and if I insert it there it will appear on all the pages under the template, i only what it to appear on one page.
    thanks in advance

    You can insert it as the first item after your <body> on that page and it should work the same way as in the header.

  • Rename audio clips within merged clips

    Hi there,
    In premiere CS5.5, is it possible to rename the audio clips that are within a merged clips ?
    I mean, with each video, I have several audio tracks from ambient and 2 booms.
    In order not to mess up with those when editing sound in ProTools later, I need to know which one is which.
    Thanks.

    If you only want the sound clip for a set period of time, drag it on top of one of the video clips near the beginning that will prevent the audio from becoming a 'background music clip'. Grab the title bar of that clip in the Project window and drag it until the whole background area changes from purple/green to the normal dark grey color of the Project window. Same would apply to your voice clips as well, just drag those sound clips right on the very middle of the thumbnail image of the video clip, and then slide it around to where it needs to be by dragging it to the left or right.

  • Conditional Insert into staging table by using sqlloader

    Hi,
    In Oracle apps I'm submitting a concurrent program programmatically which will call sqlloader and insert into a staging a table.
    This table consists of 30 columns.Program has one input parameter.If parameter value = REQUIRED Then it should insert into first three columns of staging table.If it's APPROVED then it should insert into first 10 columns of the same table.
    Data file is pipe delimited file which may or may not have all possible values :For Required,I many not have all three column values

    >
    I think you understood the thinks wrongly. OP marked UTL_FILE as the correct answer, which is again a server side solution.
    >
    Perhaps you failed to notice that the answer now marked correct was posted AFTER mine. I'm not clairvoyant and OP did not state whether a server side or client side solution was appropriate.
    I stand by my comments. Using an external table is an alternative to sql loader but, as I said, simply using an external table instead of sql loader doesn't address OPs problem.
    >
    And IMO, external table will be faster than UTL_FILE
    >
    I'd be more concerned with why OP wants to write a procedure to parse flat files, deal with data conversion errors and perform table inserts when Oracle already provides that functionality using either external tables or sql loader.
    I would suggest loading the file into a new staging table that can hold all of the columns that might be contained in the flat file. Then the appropriate data can be moved to OPs staging table according to the required business rules.
    Sounds like we each think OP should reconsider the architecture.

  • Insert within clob

    i have a CLOB datatype column how i will insert record inthis column like picture etc.

    For pictures you may need the BLOB datatype. As for examples, why not look up the user guide, it comes with a search function, you know. Here's a link for an CLOB example:
    http://download-uk.oracle.com/docs/cd/B19306_01/text.102/b14218/cdatadic.htm#sthref319
    C.

Maybe you are looking for