Conditional multitable inserts

Hi guys

Below is a question of sample size of the heading "inserts conditional multi-table. I do not understand the explanation given by the author in support of his answer.

insert
     when (part_no < 500) then
      into store_inventory (num, product)
      values (spare_id, part_name)
     into port_inventory (num, product)
      values (spare_id, part_name)
     when (part_no >= 500) then
      into ship_inventory (num, product)
      values (spare_id, part_name)
     select spare_id, part_no, part_name
     from spares;

Which of the following statements are true for this SQL query.

(A) if the first WHEN the condition on line 2 is true, the INTO clause in line 3 by line 4 will be performed, after which the respites will jump to the next line that is returned by the subquery.

(B) if the first condition WHEN line 2 is true, the condition WHEN in line 7 will not be evaluated.

(C) any IF condition is true, the line 5 INTO clause will be executed without worrying.

(D) apart from the question of whether the first WHEN condition is true or not, WHEN the second condition is evaluated.

The author says that the answer is D. He says "both WHEN the conditions will be evaluated because the conditional INSERT is an INSERT ANY State. The explanation of the authors to support the answer is no not any sense for me! Can someone explain to me?

Hello

What don't you understand? By default a multi-table insert takes as WELL as the evaluation criteria, which means all WHEN clauses will be evaluated.

This is explained in the manual SQL:

multi-table insert

http://docs.Oracle.com/CD/E11882_01/server.112/e41084/statements_9014.htm#i2095116

Tags: Database

Similar Questions

  • Makes no sense to me-multi-table INSERT alias

    small excerpt of the book, do not think that I needed to add many other things.

    So, what do we do? The solution is to specify an alias for column to all column names

    in subqueries that use a table alias, then reference it the column alias of the

    rest of the INSERT conditional statement, as we do in lines 5 and 6 below (line

    added numbers):

    01 INSERT

    02. WHAT (BOSS_SALARY-EMPLOYEE_SALARY < 10000) THEN

    03. IN SALARY_CHART (EMP_TITLE, SUPERIOR, EMP_INCOME, SUP_INCOME)

    04 VALUES (EMPLOYEE, BOSS, EMPLOYEE_SALARY, BOSS_SALARY)

    05 SELECT A.POSITION EMPLOYEE,

    06 B.POSITION BOSS,

    07 A.MAX_SALARY EMPLOYEE_SALARY,

    08 B.MAX_SALARY BOSS_SALARY

    09 FROM POSITIONS A JOIN POSITIONS B

    10. THE A.REPORTS_TO = B.POSITION_ID

    11. WHERE A.MAX_SALARY > 100000;


    Note that this version has done more than necessary and applied alias columns

    for each column in the subquery, then referenced by these column alias of the

    WHEN and VALUES clauses. We only needed columns on A.POSITION alias

    and B.POSITION in lines 5 and 6, so we can refer to the alias column to line 4.

    Whatever it is, this version of the INSERT conditional is syntactically correct.

    Uh, have we not need to alias column for lines 7 and 8, so... (as he shows)? Otherwise use table alisases for a.max_salary & b.max_salary on line 2. And using aliases table is not in the INTO s/WHEN is multitable inserts.

    Hello

    2776946 wrote:

    small excerpt from the book,

    What book?  View the full title and page number or link

    I didn't know that I had to add much.

    So, what do we do? The solution is to specify an alias for column to all column names

    in subqueries that use a table alias, then reference it the column alias of the

    rest of the INSERT conditional statement, as we do in lines 5 and 6 below (line

    added numbers):

    01 INSERT

    02. WHAT (BOSS_SALARY-EMPLOYEE_SALARY< 10000)="">

    03. IN SALARY_CHART (EMP_TITLE, SUPERIOR, EMP_INCOME, SUP_INCOME)

    04 VALUES (EMPLOYEE, BOSS, EMPLOYEE_SALARY, BOSS_SALARY)

    05 SELECT A.POSITION EMPLOYEE,

    06 B.POSITION BOSS,

    07 A.MAX_SALARY EMPLOYEE_SALARY,

    08 B.MAX_SALARY BOSS_SALARY

    09 FROM POSITIONS A JOIN POSITIONS B

    10. THE A.REPORTS_TO = B.POSITION_ID

    11. WHERE A.MAX_SALARY > 100000;

    Note that this version has done more than necessary and applied alias columns

    for each column in the subquery, then referenced by these column alias of the

    WHEN and VALUES clauses. We only needed columns on A.POSITION alias

    and B.POSITION in lines 5 and 6, so we can refer to the alias column to line 4.

    Whatever it is, this version of the INSERT conditional is syntactically correct.

    Uh, have we not need to alias column for lines 7 and 8, so... (as he shows)? Otherwise use table alisases for a.max_salary & b.max_salary on line 2. And using aliases table is not in the INTO s/WHEN is multitable inserts.

    It is true; you need an alias for at least 1 of these columns.  Each column in the query (lines 5-11), which is used elsewhere in the statement must have a unique name.  The query you posted called the columns in the result set

    employee_salary and boss_salary.   You can also use

    max_salary and patron of salary or

    employee_salary and max_salary, giving an alias to only 1 of the 2 columns, but they must have unique names.

    You're right on the table alias, too.  The scope of alias tables A and B is the query (lines 5-11).  Impossible to refer to A or B in lines 1-4.

  • Insert in OWB statement

    Hello

    How can I create a mapping in OWB 11.2 to be inserted?

    Thank you.
    -bzx

    Multi-table insert supported by OWB - use dirrectly operator splitter before the target tables and do not forget to specify the condition on the output group.
    but there are limitations on the use of additional operators after spilltter - look at this thread (for example if you add after separator filter operator OWB generated stop multitable insert statement):
    How to use Oracle 10 G SQL features in OWB?

    Kind regards
    Oleg

  • Display error message when a condition in the process page returns false

    Hello

    I doubt by displaying the error message in a page. In my treatment of the page, I have a process that is assosiated with

    a press the button. In the process, I have an 'if' condition and insert in a table when the "If" condition returns true. If

    It returns false that I need to display an error message like "cannot insert a value. I tried to give him in the error of process

    message, but it is not displaying when the if condition fails. Help, please


    Thank you

    TJ

    Edited by: tj2010 Oct 6, 2009 21:25

    Hello

    Have you tried

    If condition = true
    then
    insert into the table;
    on the other
    apex_application.g_print_success_message: = "your Message here";
    end if;

    Make sure that the branch on the page that is triggered after your process has the "success of process message includes" checked.

    Concerning

    Paul

  • How can I do a new insert data in the other table extrancting?

    Hello, I'm looking how to do an insertion of two tables save values and apply to other tables like this:

    The insert I'm looking for is something like this:

    Have two tables, the first table is emp1 and contains the column: data 1 and 2 with line of data1: 1234 and line data 2:5555, therefore,.

    I want to create an insert on a new table called (emp2) that contain the data in the column: data 1, data 2 (from the first table demo1), data 3, data 4, etc.

    How insert again I can put / call data from another table insert in this table (emp2).

    I don't know if my example is correct (my English is very bad).

    This is an example: (sorry for the points).

    table EMP2:

    1 data... 2 data... 3 data... data 4... data 5
    (from emp1)... (from emp1)... 8534... 2347... 4544

    Thanks for the help.

    Published by: user10182692 on 24-May-2009 08:39

    Published by: user10182692 on 24-May-2009 08:40

    Published by: user10182692 on 24-May-2009 08:45

    Welcome! on the forum.

    You can include the code and data in the {code} tags

    If I'm good, and I know what is your condition

    insert into emp2 ( data1, data2)
    select data1, data2
    from emp1
    

    SS

  • Browsing through the values of multi-donnees block against certain values BEFORE UPDATE! (FORMS 10G)

    I have a form with 2 blocks: a tabular and a single.

    I need to check a condition before INSERT/update to each record.

    To insert, I do this in WHEN_VALIDATE_RECORD and its working perfectly fine.

    However, to insert, as only the updated records are validated if its does not work very well against all records.

    How to browse and check all records against a condition on the UPDATE.

    I tried go_block, loop, depending on type of logical record in pre_update and pre_commit, but they are limited to these triggers.

    How to solve this problem?

    Kind regards

    Misbah.

    What I mean is that you must take logic out-pre - COMMIT because you can't do a GO_BLOCK.  Instead, you need to transfer this logic in triggering the COMMIT BUTTON.  It is not limited, so he can make the GO_BLOCK, NEXT_RECORD, etc...

  • Error with the inclusion of values

    Hi guys, how are you?

    I want to do a function or a procedure that is dealing with two tables.

    I have 1 table which is the storage table. I have two columns.

    Good_name | Quantity

    __________________________

    The Bill table has several columns, including

    Good_name and quantity.

    Now let's say that if I have the following text in the table of storage;

    Good_name | Quantity

    Pencil of 30

    _______________________________

    The Bill table will be filled as follows:

    Good_name | Quantity

    15 pencil

    _________________________________________

    in this case, after the filling of the 15 field. I want to do a subtraction in the table of storage inside a trigger. I used the following code, but it doesn't seem to work.

    In the quantity of items after filling:

    DECLARE

    number of result;

    number of enter_val: =: BUYER_ENTERY_TABLE. QUANTITY;

    number of new_val;

    good varchar2 (500): =: BUYER_ENTERY_TABLE. GOOD_NAME;

    Begin

    Select the quantity in the result

    invoice

    where GOOD_NAME = good;

    new_val: result = - enter_val;

    If (new_val > 0)

    THEN

    insert into BILL (Quantity)

    values (new_val)

    where good_name = good;

    : BUYER_ENTERY_TABLE. QUANTITY: = enter_val;

    SETSTORAGE (enter_val, Good);

    Elsif (new_val = 0)

    Then

    insert into BILL (Quantity)

    values (new_val)

    where good_name = good;

    SETSTORAGE (enter_val, Good);

    ON THE OTHER

    message (' you entered more in stock ""); message(' ');

    : BUYER_ENTERY_TABLE. QUANTITY: = 0;

    END IF;

    END;

    I get errors in which the condition.

    All decisions

    Hello

    You can't put a 'WHERE' condition in INSERT statement n.

    What follows:

    insert into BILL (Quantity)

    values (new_val)

    where good_name = good;

    should be reduced to:

    insert into BILL (Quantity)

    values (new_val);

  • ORA-03113 "reading" XML of CLOB

    Hello

    I use XMLTable for reading XML to insert data into the DB table. I have:

    PROCEDURE IMPORT_XML)

    p_plik VARCHAR2,

    p_tp_id NUMBER,

    number of p_commit_po: = 500) IS

    l_blob_id TERYT_PLIKI.tp_blob_id%type;

    l_blob BLOB;

    XMLTYpe l_teryt_xml;

    L_Name varchar2 (100);

    l_type varchar2 (100);

    l_date varchar2 (100);

    -l_part varchar2 (100);

    XMLType l_rows;

    l_commit number (6);

    l_cnt_rows NUMBER: = 0;

    procedure do_commit is

    Start

    l_commit: = l_commit + 1;

    l_cnt_rows: = l_cnt_rows + 1;

    If l_commit > = p_commit_po then

    commit;

    l_commit: = 0;

    end if;

    end do_commit;

    BEGIN

    -# variable l_BLOB contains BLOB from a column of table #.

    Err.d ("convert BLOB CLOB type...', 'IMPORT_XML', 70 ');

    declare

    dest_lob CLOB.

    src_lob BLOB;

    the sum integer: = DBMS_LOB. LOBMAXSIZE;

    dest_offset integer: = 1;

    offset integer: = 1;

    number of blob_csid: = nls_charset_id ('AL32UTF8');

    lang_context integer: = 0;

    the warning integer: = DBMS_LOB. WARN_INCONVERTIBLE_CHAR;

    Start

    dest_lob: = empty_Clob();

    DBMS_LOB. CREATETEMPORARY (dest_lob, false);

    DBMS_LOB. OPEN (dest_lob, DBMS_LOB. LOB_READWRITE);

    DBMS_LOB. OPEN (l_blob, DBMS_LOB. LOB_READONLY);

    DBMS_LOB. () CONVERTTOCLOB

    dest_lob,

    l_blob,

    amount,

    dest_offset,

    offset,

    blob_csid,

    lang_context,

    (caveat);

    DBMS_LOB. Close (l_blob);

    l_teryt_xml: = XMLType (dest_lob);

    commit;

    DBMS_LOB. FREETEMPORARY (dest_lob);

    end;

    l_rows: = l_teryt_xml.extract('/teryt/catalog/row');

    l_commit: = 0;

    If l_name = "TERC" then

    Err.d ("name =" |) L_Name, cm, 80);

    for r in (SELECT x.*

    FROM XMLTable ('/ rank ' ADOPTION l_rows)

    ["COLUMNS"WOJ"PATH of the VARCHAR2 (20) ' col[@name="WOJ "]',

    ["VARCHAR2 (20)"POW"PATH" col[@name="POW"]',

    ["Path"GMI"VARCHAR2 (20) ' col[@name="GMI "]',

    PATH of VARCHAR2 (2) "RODZ" "col[@name="RODZ"]',"

    PATH of VARCHAR2 (50) "NAME" "col[@name="NAZWA"]',"

    PATH of VARCHAR2 (50) "NAZDOD" "col[@name="NAZDOD"]',"

    "[" "STAN_NA PATH" VARCHAR2 (10) ' col[@name="STAN_NA"] "

    ) x

    ) loop

    INSERT INTO TERYT_TERC (WOJ, POW, GMI, RODZ, NAME, NAZDOD, STAN_NA, TP_ID)

    VALUES (r.WOJ, r.POW, r.GMI, r.RODZ, r.NAZWA, r.NAZDOD, r.STAN_NA, P_TP_ID);

    do_commit;

    end loop;

    elsif l_name = "SIMC" then

    Err.d ("name =" |) L_Name, cm, 80);

    for r in (SELECT x.*

    FROM XMLTable ('/ rank ' ADOPTION l_rows)

    "WOJ" VARCHAR2 COLUMNS (3) path "col[@name="WOJ"]',"

    ["" POW"VARCHAR2 (3) path" col[@name="POW"]',

    "GMI" VARCHAR2 (3) PATH "col[@name="GMI"]',"

    PATH of VARCHAR2 (2) "RODZ_GMI" "col[@name="RODZ_GMI"]',"

    ["" RM"VARCHAR2 (3) path" col[@name="RM"]',

    "MZ' VARCHAR2 (3) PATH" col[@name="MZ"]', "

    PATH of VARCHAR2 (60) "NAME" "col[@name="NAZWA"]',"

    "SYM' VARCHAR2 (7) PATH" col[@name="SYM"]', "

    PATH of VARCHAR2 (7) "SYMPOD" "col[@name="SYMPOD"]',"

    PATH of VARCHAR2 (10) "STAN_NA" "col[@name="STAN_NA"]"

    ) x

    ) loop

    INSERT INTO TERYT_SIMC (WOJ, POW, GMI, RODZ_GMI, RM, MZ, NAME, SYMBOL, SYMPOD, STAN_NA, TP_ID)

    VALUES (r.WOJ, r.POW, r.GMI, r.RODZ_GMI, r.RM, r.MZ, r.NAZWA, r.SYM, r.SYMPOD, r.STAN_NA, P_TP_ID);

    do_commit;

    end loop;

    elsif l_name = "ULIC" then

    Err.d ("name =" |) L_Name, cm, 80);

    for r in (SELECT x.*

    FROM XMLTable ('/ rank ' ADOPTION l_rows)

    "WOJ" VARCHAR2 COLUMNS (3) path "col[@name="WOJ"]',"

    ["" POW"VARCHAR2 (3) path" col[@name="POW"]',

    "GMI" VARCHAR2 (3) PATH "col[@name="GMI"]',"

    PATH of VARCHAR2 (2) "RODZ_GMI" "col[@name="RODZ_GMI"]',"

    "SYM' VARCHAR2 (7) PATH" col[@name="SYM"]', "

    PATH of VARCHAR2 (7) "SYM_UL" "col[@name="SYM_UL"]',"

    PATH of VARCHAR2 (5) "CECHA" "col[@name="CECHA"]',"

    PATH of VARCHAR2 (50) "NAZWA_1" "col[@name="NAZWA_1"]',"

    PATH of VARCHAR2 (50) "NAZWA_2" "col[@name="NAZWA_2"]',"

    PATH of VARCHAR2 (10) "STAN_NA" "col[@name="STAN_NA"]"

    ) x

    ) loop

    INSERT INTO TERYT_ULIC (WOJ, POW, GMI, RODZ_GMI, SYM, SYM_UL, CECHA, NAZWA_1, NAZWA_2, STAN_NA, TP_ID)

    VALUES (r.WOJ, r.POW, r.GMI, r.RODZ_GMI, r.SYM, r.SYM_UL, r.CECHA, r.NAZWA_1, r.NAZWA_2, r.STAN_NA, P_TP_ID);

    do_commit;

    end loop;

    elsif l_name = "WMRODZ" then

    Err.d ("name =" |) L_Name, cm, 80);

    for r in (SELECT x.*

    FROM XMLTable ('/ rank ' ADOPTION l_rows)

    "RM" VARCHAR2 COLUMNS (5) path "col[@name="RM"]',"

    PATH of VARCHAR2 (50) "NAZWA_RM" "col[@name="NAZWA_RM"]',"

    PATH of VARCHAR2 (10) "STAN_NA" "col[@name="STAN_NA"]"

    ) x

    ) loop

    INSERT INTO TERYT_WMRODZ (RM, NAZWA_RM, STAN_NA, TP_ID)

    VALUES (r.RM, r.NAZWA_RM, r.STAN_NA, P_TP_ID);

    do_commit;

    end loop;

    end if;

    validation work;


    When I'm loading file of type "SIMC" (the file size is approximately 32 MB), all right.

    When I am trying to load the "NEW" type (size file is about 80 MB), there's an ORA-03113.


    The problem is with the LOOP SELECTION, because

    Err.d ("name =" |) L_Name, cm, 80);

    connects name = ULIC


    What can I do to fix this?

    My DB is: Oracle Database 11 g Release 11.2.0.4.0 - 64 bit Production

    As Jason said, there are a bunch of useless stuff in there:

    -The VALIDATION inside the loop: do not do, commit only once, after that the job is done.

    -FOR lines: do not do this, use only one (possibly multi-table) INSERT SELECT.

    -BLOB CLOB conversion: not necessary, use the XMLTYPE constructor.

    -Extract from the XML document, that the work of the intermediate parties do in the whole structure directly.

    Basically, your procedure can be simplified to this couple of statements:

    -- insert XML into a temporary binary XMLType table, for performance :
    insert into tmp_xml values ( xmltype(l_blob, nls_charset_id('AL32UTF8')) );
    
    -- multitable insert into the target tables :
    INSERT FIRST
    WHEN l_name = 'TERC' THEN INTO
      TERYT_TERC (WOJ, POW, GMI, RODZ, NAZWA, NAZDOD, STAN_NA, TP_ID)
      VALUES (WOJ, POW, GMI, RODZ, NAZWA, NAZDOD, STAN_NA, P_TP_ID)
    WHEN l_name = 'SIMC' THEN INTO
      TERYT_SIMC (WOJ, POW, GMI, RODZ_GMI, RM, MZ, NAZWA, SYM, SYMPOD, STAN_NA, TP_ID)
      VALUES (WOJ, POW, GMI, RODZ_GMI, RM, MZ, NAZWA, SYM, SYMPOD, STAN_NA, P_TP_ID)
    WHEN l_name = 'ULIC' THEN INTO
      TERYT_ULIC (WOJ, POW, GMI, RODZ_GMI, SYM, SYM_UL, CECHA, NAZWA_1, NAZWA_2, STAN_NA, TP_ID)
      VALUES (WOJ, POW, GMI, RODZ_GMI, SYM, SYM_UL, CECHA, NAZWA_1, NAZWA_2, STAN_NA, P_TP_ID)
    WHEN l_name = 'WMRODZ' THEN INTO
      TERYT_WMRODZ (RM, NAZWA_RM, STAN_NA, TP_ID)
      VALUES (RM, NAZWA_RM, STAN_NA, P_TP_ID)
    SELECT x.*
    FROM tmp_xml t
       , XMLTable('/teryt/catalog/row'
           PASSING t.object_value
           COLUMNS "WOJ"      VARCHAR2(20) PATH 'col[@name="WOJ"]',
                   "POW"      VARCHAR2(20) PATH 'col[@name="POW"]',
                   "GMI"      VARCHAR2(20) PATH 'col[@name="GMI"]',
                   "RODZ"     VARCHAR2(2)  PATH 'col[@name="RODZ"]',
                   "NAZWA"    VARCHAR2(50) PATH 'col[@name="NAZWA"]',
                   "NAZDOD"   VARCHAR2(50) PATH 'col[@name="NAZDOD"]',
                   "STAN_NA"  VARCHAR2(10) PATH 'col[@name="STAN_NA"]',
                   "RODZ_GMI" VARCHAR2(2)  PATH 'col[@name="RODZ_GMI"]',
                   "RM"       VARCHAR2(3)  PATH 'col[@name="RM"]',
                   "MZ"       VARCHAR2(3)  PATH 'col[@name="MZ"]',
                   "SYM"      VARCHAR2(7)  PATH 'col[@name="SYM"]',
                   "SYMPOD"   VARCHAR2(7)  PATH 'col[@name="SYMPOD"]',
                   "SYM"      VARCHAR2(7)  PATH 'col[@name="SYM"]',
                   "SYM_UL"   VARCHAR2(7)  PATH 'col[@name="SYM_UL"]',
                   "CECHA"    VARCHAR2(5)  PATH 'col[@name="CECHA"]',
                   "NAZWA_1"  VARCHAR2(50) PATH 'col[@name="NAZWA_1"]',
                   "NAZWA_2"  VARCHAR2(50) PATH 'col[@name="NAZWA_2"]',
                   "NAZWA_RM" VARCHAR2(50) PATH 'col[@name="NAZWA_RM"]'
         ) x
    ;
    

    where TMP_XML is defined as follows:

    create global temporary table tmp_xml of xmltype
    xmltype store as securefile binary xml;
    
  • confirmation box between different processes

    Hello world

    Here's the scenario:

    I have two processes on the page:
    1-insert/update of the data.
    2. to send the e-mail.

    The reqirement is to have the process to run on the same click of button and 'send email' process should be based on the question of whether or not the user selects Yes.

    Based on other threads on the forum, I know how to add a confirmation box if there is that a single process, but who have a time difficult, how can it make using multiple processes and add them confirmation box.

    Please advise me.

    Thank you
    Wojtek

    Published by: Wojtek on October 12, 2010 14:35

    Create the javascript function, for example

      function sumbit_page(){
         if(confirm('Do you want to send e-mail after...')){
           doSubmit('SEND_MAIL');
         }else{
           doSumbit('JUST_SUMBIT');
         }
      }
    

    and call on click of a button.

    Then change your processes to be conditional:
    (1) insert/update data if: ASK ("SEND_MAIL', 'JUST_SUBMIT')
    (2) e-mail: REQUEST = 'SEND_MAIL '.

    __________________________
    Don't forget to mark the appropriate fix/useful messages

  • The terms of outbound merger works is not with the information in 10g

    Hello

    Here are the details of my local and remote database database
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for HPUX: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    I do a merger in a remote database from a local table using query below...
    MERGE into sap_mmd_po_all@cosmic_dev.somedomainname trg using (select * from sap_mmd_cmas_po where upload_flag in ('I','U')) src
      on (trg.PO_NO=src.PO_NO and trg.LINE_DISTRIB_SEQ=src.LINE_DISTRIB_SEQ)
      WHEN MATCHED THEN
        update set 
          trg.PO_STATUS_FLG=src.PO_STATUS_FLG,
          trg.SHIP_TO_FACILITY_CD=src.SHIP_TO_FACILITY_CD,
          trg.DELV_TO_PHONE_NO=src.DELV_TO_PHONE_NO,
          trg.DELV_TO_NM=src.DELV_TO_NM,
          trg.DELV_TO_ADDRESS_1=src.DELV_TO_ADDRESS_1,
          trg.PO_ITEM_NO=src.PO_ITEM_NO,
          trg.ITEM_DESCRP=src.ITEM_DESCRP,
          trg.PARTY_NM=src.PARTY_NM,
          trg.VENDOR_ITEM_ID=src.VENDOR_ITEM_ID,
          trg.PO_LN_CRTE_DT=src.PO_LN_CRTE_DT,
          trg.BILL_UOM_CD=src.BILL_UOM_CD,
          trg.COMMODITY_CD=src.COMMODITY_CD,
          trg.COMMODITY_NM=src.COMMODITY_NM,
          trg.BSNSS_UNIT_NO=src.BSNSS_UNIT_NO,
          trg.PO_LN_ORD_QTY=src.PO_LN_ORD_QTY,
          trg.DISTRIB_AMT=src.DISTRIB_AMT,
          trg.PO_LN_DEL_IND=src.PO_LN_DEL_IND,
          trg.PO_DEL_IND=src.PO_DEL_IND,
          trg.PO_TYPE=src.PO_TYPE,
          trg.DOC_DATE=src.DOC_DATE,
          trg.CRTE_DT_TM=src.CRTE_DT_TM,
          trg.UPD_DT_TM=systimestamp,
          trg.SOURCE_SYSTEM=src.SOURCE_SYSTEM,
          trg.PO_LN_LST_CHNGE_DT=src.PO_LN_LST_CHNGE_DT,
          trg.TXJCD=src.TXJCD,
          trg.PLANT=src.PLANT 
          where (src.upload_flag='U')--if i remove this then it is working
      WHEN NOT MATCHED THEN
        insert( trg.PO_NO,
                trg.LINE_DISTRIB_SEQ,
                trg.PO_STATUS_FLG,
                trg.SHIP_TO_FACILITY_CD,
                trg.DELV_TO_PHONE_NO,
                trg.DELV_TO_NM,
                trg.DELV_TO_ADDRESS_1,
                trg.PO_ITEM_NO,
                trg.ITEM_DESCRP,
                trg.PARTY_NM,
                trg.VENDOR_ITEM_ID,
                trg.PO_LN_CRTE_DT,
                trg.BILL_UOM_CD,
                trg.COMMODITY_CD,
                trg.COMMODITY_NM,
                trg.BSNSS_UNIT_NO,
                trg.PO_LN_ORD_QTY,
                trg.DISTRIB_AMT,
                trg.PO_LN_DEL_IND,
                trg.PO_DEL_IND,
                trg.PO_TYPE,
                trg.DOC_DATE,
                trg.CRTE_DT_TM,
                trg.UPD_DT_TM,
                trg.SOURCE_SYSTEM,
                trg.PO_LN_LST_CHNGE_DT,
                trg.TXJCD,
                trg.PLANT) 
        values( src.PO_NO,
                src.LINE_DISTRIB_SEQ,
                src.PO_STATUS_FLG,
                src.SHIP_TO_FACILITY_CD,
                src.DELV_TO_PHONE_NO,
                src.DELV_TO_NM,
                src.DELV_TO_ADDRESS_1,
                src.PO_ITEM_NO,
                src.ITEM_DESCRP,
                src.PARTY_NM,
                src.VENDOR_ITEM_ID,
                src.PO_LN_CRTE_DT,
                src.BILL_UOM_CD,
                src.COMMODITY_CD,
                src.COMMODITY_NM,
                src.BSNSS_UNIT_NO,
                src.PO_LN_ORD_QTY,
                src.DISTRIB_AMT,
                src.PO_LN_DEL_IND,
                src.PO_DEL_IND,
                src.PO_TYPE,
                src.DOC_DATE,
                systimestamp,
                src.UPD_DT_TM,
                src.SOURCE_SYSTEM,
                src.PO_LN_LST_CHNGE_DT,
                src.TXJCD,
                src.PLANT)
                where src.upload_flag='I'--if i remove this then it is working
                ;
    And it is throwing an error like...
    SQL Error: ORA-00904: "A3"."UPLOAD_FLAG": invalid identifier
    But when I replace the name of the remote table with the name of the local table and query works fine...
    table structure in local database..
    CREATE TABLE SAP_MMD_CMAS_PO
       (     "PO_NO" VARCHAR2(10 BYTE) NOT NULL ENABLE, 
         "LINE_DISTRIB_SEQ" NUMBER NOT NULL ENABLE, 
         "PO_STATUS_FLG" VARCHAR2(40 BYTE), 
         "SHIP_TO_FACILITY_CD" VARCHAR2(100 BYTE), 
         "DELV_TO_PHONE_NO" VARCHAR2(50 BYTE), 
         "DELV_TO_NM" VARCHAR2(100 BYTE), 
         "DELV_TO_ADDRESS_1" VARCHAR2(1000 BYTE), 
         "PO_ITEM_NO" VARCHAR2(100 BYTE), 
         "ITEM_DESCRP" VARCHAR2(200 BYTE), 
         "PARTY_NM" VARCHAR2(1000 BYTE), 
         "VENDOR_ITEM_ID" VARCHAR2(100 BYTE), 
         "PO_LN_CRTE_DT" TIMESTAMP (6), 
         "BILL_UOM_CD" VARCHAR2(50 BYTE), 
         "COMMODITY_CD" VARCHAR2(50 BYTE), 
         "COMMODITY_NM" VARCHAR2(50 BYTE), 
         "BSNSS_UNIT_NO" VARCHAR2(50 BYTE), 
         "PO_LN_ORD_QTY" NUMBER, 
         "DISTRIB_AMT" NUMBER, 
         "PO_LN_DEL_IND" VARCHAR2(10 BYTE), 
         "PO_DEL_IND" VARCHAR2(10 BYTE), 
         "PO_TYPE" VARCHAR2(10 BYTE), 
         "DOC_DATE" TIMESTAMP (6), 
         "CRTE_DT_TM" TIMESTAMP (6), 
         "UPD_DT_TM" TIMESTAMP (6), 
         "SOURCE_SYSTEM" VARCHAR2(100 BYTE), 
         "PO_LN_LST_CHNGE_DT" TIMESTAMP (6), 
         "TXJCD" VARCHAR2(50 BYTE), 
         "PLANT" VARCHAR2(10 BYTE), 
         "UPLOAD_FLAG" VARCHAR2(1 BYTE), 
          PRIMARY KEY ("PO_NO", "LINE_DISTRIB_SEQ")
      )
    --table structure in remote database table
    CREATE TABLE SAP_MMD_PO_ALL
       (     "PO_NO" VARCHAR2(10 BYTE) NOT NULL ENABLE, 
         "LINE_DISTRIB_SEQ" NUMBER NOT NULL ENABLE, 
         "PO_STATUS_FLG" VARCHAR2(40 BYTE), 
         "SHIP_TO_FACILITY_CD" VARCHAR2(100 BYTE), 
         "DELV_TO_PHONE_NO" VARCHAR2(50 BYTE), 
         "DELV_TO_NM" VARCHAR2(100 BYTE), 
         "DELV_TO_ADDRESS_1" VARCHAR2(1000 BYTE), 
         "PO_ITEM_NO" VARCHAR2(100 BYTE), 
         "ITEM_DESCRP" VARCHAR2(200 BYTE), 
         "PARTY_NM" VARCHAR2(1000 BYTE), 
         "VENDOR_ITEM_ID" VARCHAR2(100 BYTE), 
         "PO_LN_CRTE_DT" TIMESTAMP (6), 
         "BILL_UOM_CD" VARCHAR2(50 BYTE), 
         "COMMODITY_CD" VARCHAR2(50 BYTE), 
         "COMMODITY_NM" VARCHAR2(50 BYTE), 
         "BSNSS_UNIT_NO" VARCHAR2(50 BYTE), 
         "PO_LN_ORD_QTY" NUMBER, 
         "DISTRIB_AMT" NUMBER, 
         "PO_LN_DEL_IND" VARCHAR2(10 BYTE), 
         "PO_DEL_IND" VARCHAR2(10 BYTE), 
         "PO_TYPE" VARCHAR2(10 BYTE), 
         "DOC_DATE" TIMESTAMP (6), 
         "CRTE_DT_TM" TIMESTAMP (6), 
         "UPD_DT_TM" TIMESTAMP (6), 
         "SOURCE_SYSTEM" VARCHAR2(100 BYTE), 
         "PO_LN_LST_CHNGE_DT" TIMESTAMP (6), 
         "TXJCD" VARCHAR2(50 BYTE), 
         "PLANT" VARCHAR2(10 BYTE), 
         "DELETE_FLAG" VARCHAR2(1 BYTE) DEFAULT 'N', 
          PRIMARY KEY ("PO_NO", "LINE_DISTRIB_SEQ")
      )
    It seems to me like a bug, but not quite sure...
    your suggestions are appreciated.

    Thank you
    Ravi Kumar

    Published by: ravikumar.sv on December 14, 2009 13:31
    Commented the where query merger conditions

    In fact I need to hit two conditions as upload_flag ='U or upload_flag 'I' = here.
    When the flag is 'U' in the source, then I need to update in the remote database
    and
    When the 'I' flag is in the source, then I need to insert into the remote database.

    So I need to write the where condition them in update and insert the clause...
    Do you think that anyway it can be bypassed by using a single merge stmt... ?

    No, do not write condition for INSERT since you're selectiing only I and U flag.

    select * from sap_mmd_cmas_po where upload_flag in ('I','U')) 
    

    The slot game to 'U' condition and all WITHOUT corresponding lines obviously will be that I have.

    on (trg.PO_NO=src.PO_NO and trg.LINE_DISTRIB_SEQ=src.LINE_DISTRIB_SEQ AND src.upload_flag='U')
    

    See you soon,.
    Avinash

  • data type conversion error

    Hello
    I have the insert under certain conditions
    insert into temp1(no number) 
     SELECT (CASE WHEN TO_NUMBER(TO_CHAR(SYSDATE,'DDMMYYYY')) BETWEEN                                 TO_NUMBER(TO_CHAR(START_DATE,'DDMMYYYY')) AND
             TO_NUMBER(TO_CHAR(END_DATE,'DDMMYYYY'))
            THEN NVL(ORG_ID,0) ELSE 0 END)
    FROM temp2;
    but get the following error:

    ERROR at line 3:
    ORA-00932: inconsistent data types: expected TANK got the NUMBER


    could you please give hint to resolve this error:

    Josh

    If your arguments start_date and end_date DATE data type, then you can simply use TRUNC

    INSERT INTO temp1(no)
    SELECT CASE WHEN TRUNC(sysdate) BETWEEN TRUNC(start_date) AND TRUNC(end_date)
                 THEN NVL(TO_NUMBER(org_id),0)
                ELSE 0
           END
      FROM temp2
    
  • Problem with date validation

    My table contains a column whose name is "time". This column type is DATE and the date format ' DD-MON-YYYY HH24 ". My problem is that I have no idea of how to write well validate the condition to insert in my table only the dates, hours are between 08:00 and 16:00.
    Many thanks for your help :)

    Hello

    Have a look here: http://examples.apex-evangelists.com/pls/apex/f?p=286:49

    Validation is SQL exists:

    SELECT 1
    FROM DUAL
    WHERE TO_DATE(:P49_TIME,'YYYY-MM-DD HH24:MI')
          BETWEEN TRUNC(TO_DATE(:P49_TIME,'YYYY-MM-DD HH24:MI'))+8/24
              AND TRUNC(TO_DATE(:P49_TIME,'YYYY-MM-DD HH24:MI'))+16/24
    

    Kind regards
    Dimitri
    http://dgielis.blogspot.com/
    http://www.apex-evangelists.com/
    http://www.apexblogs.info/

  • PL/SQL insert based on conditions

    I'd appreciate any help I can get. I learn PL/SQL and have stumbled upon a problem, so please help me to find an appropriate way to deal with this situation I am running Oracle 11 GR 2

    My diagram:

    CREATE TABLE "ENTRY"
    (
    'TYPE' VARCHAR2 (5 CHAR) ,
    'TRANSACTION' VARCHAR2()5 TANK),
    'OWNER' VARCHAR2 (5 CHAR)
    ); 

    CREATE TABLE "VIEW"
    (
    'TYPE' VARCHAR2 (5 CHAR) ,
    'TRANSACTION' VARCHAR2 (5 CHAR),
    'OWNER' VARCHAR2 (5 CHAR)
    ); 

    CREATE TABLE "REJECTED"
    (
    'TYPE' VARCHAR2 (5 CHAR) ,
    'TRANSACTION' VARCHAR2 (5 CHAR),
    'OWNER' VARCHAR2 (5 CHAR)
    );

    My sample data:

    insert into entry (type, transaction, owner) values (11111, 11111, 11111);
    insert into entry (type, transaction, owner) values (22222, 22222, 22222);

    Now for the confusing part, I wrote this procedure which has to copy the values from the table ENTRY in the table VIEW if a record is no specific combination (transaction AND owner). If such an association exists in the table for VIEW this record should then go to the REJECTED table. This procedure done that but on the executions of the procedure, I get more entries in the REJECTED table so my question is how do to limit inserts them into the table of REJECTED - if a record already exists in the REJECTED table then do nothing.

    create or replace PROCEDURE COPY AS 
    v_owner_entry ENTRY
    .owner%TYPE;
    v_transaction_entry ENTRY
    .transaction%TYPE; 
    v_owner
    VIEW.owner%TYPE;
    v_transaction
    VIEW.transaction%TYPE; 

    begin 

    begin 
    select e.owner, e.transaction, v.owner, v.transaction
    into v_owner_entry, v_transaction_entry, v_owner, v_transaction
    from entry e, view v
    where e.owner = v.owner and e.transaction = v.transaction; 


    EXCEPTION
    when too_many_rows
    then insert into REJECTED ( TYPE, TRANSACTION, OWNER ) SELECT s1.TYPE, s1.TRANSACTION, s1.OWNER FROM ENTRY s1; 

    when no_data_found THEN  insert into VIEW ( TYPE, TRANSACTION, OWNER ) SELECT s.TYPE, s.TRANSACTION, s.OWNER FROM ENTRY s; 
    end;
    end;

    Any suggestions guys?

    See you soon!

    UPDATE

    Sorry if the original message was not enough - clear the procedure must replicate data (on a daily basis) of DB1 to DB2 and insert in the VIEW or REJECTED depending on the conditions. Here is a picture, it would be perhaps more clearly:

    replicate.jpg

    Hello

    your procedure could look something like this:

    declare
      -- Local variables here
      i integer;
    begin
      -- Test statements here
      INSERT INTO REJECTED
      (TYPE, TRANSACTION, OWNER)
      SELECT ENTRY.TYPE, ENTRY.TRANSACTION, ENTRY.OWNER
        FROM ENTRY, VIEW
       WHERE ENTRY.OWNER = VIEW.OWNER
         AND ENTRY.TRANSACTION = VIEW.TRANSACTION
         AND NOT EXISTS
       (SELECT NULL
                FROM REJECTED VW2
               WHERE VW2.OWNER = ENTRY.OWNER
                 AND VW2.TRANSACTION = ENTRY.TRANSACTION);
    
    INSERT INTO VIEW
      (TYPE, TRANSACTION, OWNER)
      SELECT TYPE, TRANSACTION, OWNER
        FROM ENTRY
       WHERE NOT EXISTS (SELECT NULL
                FROM VIEW
               WHERE ENTRY.OWNER = VIEW.OWNER
                 AND ENTRY.TRANSACTION = VIEW.TRANSACTION);
    COMMIT;
    end;
    

    Edited: Use SQL syntax

  • condition tag applied to insert to insert text not hiding all the Insert

    Hi all

    I am running FM12.0.2.389 on Win7-SP1 (64-bit) laptop with i7 & 16 GB of RAM.

    As Arnis had mentioned on a post on the use of tags condition with tables, applying the condition for the character of point tag insertion conceals the entire table when you hide that tag. It's the way I always saw tags condition applied to the insert text, too much work. However, this is not what I see now, but I don't know if what I'm seeing is "as expected" typical behavior, or a new change since FM9 (jumped FM9 FM12), or if there is a problem with my installation of FM. "."

    Here's the scenario: I have FM files that serve as overlays of text in multiple documents ("insert FMs" for clarity). The entire library of files FM has deployed several condition tags and variable to accommodate more boundaries between nearly identical products, U.S. / International English and more short documents output the same set of source files. For the sake of discussion, I'll use an example which includes 4 labels of condition:

    • 3D (specific products)
    • LI (specific products)
    • Kit (specific output)
    • Installation (specific output)

    Insert FM has 3D and LI tags as appropriate. Container FM has 4 of all labels in the game. The tag is the FM Kit insert insert text for the Insert marker. When I'm running Kit, I can show 3D or LI and achieve the expected results. However, when I hide Kit, text inside of the FM which is tagged with insert regardless of the specific tag always present, even if the rest of the FM in medallion is hidden. I am pleased to provide you with a ZIP of the files needed to use as a sample.

    I don't remember ever having this problem in FM7 or FM8 FM9. (I was a user of FM since the FM5.5 and the use of tags condition since FM6.) Is this normal? Is this a change designed as? Or am I facing a sort of weird corruption of my particular FM installation?

    Thank you

    René

    Hi René,.

    A text overlay behaves in a similar way to a table. It is anchored at the insertion point, and you apply the condition to the anchor to condition it. When you apply the condition to the Insert, all content conditionally marked in the box becomes a combined condition, i.e. the Insert with 3D and conditions of LI now has Kit, Kit & 3D and conditions of Kit & LI.

    Therefore, you have to build the Boolean expression to show or hide so combined cases. In order to hide the KIT and 3D interior and conditions LI of the Insert, the Boolean expression would be:

    not ("Kit" or (("Kit" et "3D") or ('Kit' and 'LI')))

    Simply hide only Kit will not hide a combined condition (e.g. Kit & 3D).

  • Insert data into the same table based on certain conditions

    Hello. I'm new to this forum.
    I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:

    Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
    I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:

    1. if PaidAmount > 0 & & CurrentInstallment < TotalInstallment then

    CurrentInstallment = CurrentInstallment + 1

    2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...

    So, I have to insert data by incrementing the month and year. for example:

    If currentdata is 11/2012 next data will be 12/2012

    But following will be 01, 2013
    I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit on each record selected and insert data and then turns them into table (MYTABLE) even.

    How to achieve that?

    Thank you.

    978184 wrote:
    Hello. I'm new to this forum.
    I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:

    Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
    I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:

    1. if PaidAmount > 0 & CurrentInstallment

    CurrentInstallment = CurrentInstallment + 1

    2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...

    So, I have to insert data by incrementing the month and year. for example:

    If currentdata is 11/2012 next data will be 12/2012

    But following will be 01, 2013
    I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit & on each of the selected data record and insert then turns them into table (MYTABLE).

    You can do this way:

    This is not tested, but if you can provide the example of table structure and data (IN create table and insert scripts), it can be put to the test.

    insert into your_table
    (col1, col2, col3...current_installment, month_field)
    select col1, col2, col3..,
           current_installment +
           case when paidamount > 0 and current_installment < total_installment then
            row_number() over (
                                partition by column1, column2,.. columnn      -->You may choose partition if you want the
                                                                              --Increment of Current_installment to reset after particular combination ends
                                order by primary_key        -->Order the Increment, you may choose to add more columns to order by
                              )
          else
            0                                               --> if condition is not met, then Add 0
          end curr_installment,
          add_months(to_date(month_field, 'MM/YYYY'), 1) nxt_month
      from your_table;
    

Maybe you are looking for

  • Headphone listening or connection of the Audio System to the Satellite A100

    Is it possible to connect to the connector of the helmet on the front of my A100-233, a powerful external audio system?

  • Installed update - Bad Pool - BSOD

    Hi HP supports, New computer with Windows 7 Home Premium, 64-bit.   Installed the software according to the Web site and no problem.  However, I can't use the scanner at all. HP Photosmart C6180 all-in-One Printer http://h10025.www1.hp.com/ewfrf/wc/s

  • HP Notebook 2000 network drivers

    Can you please help me with drivers... Thank you... Network controller: PCI\VEN_10EC & DEV_8176 & SUBSYS_1629103C & REV_01PCI\VEN_10EC & DEV_8176 & SUBSYS_1629103CPCI\VEN_10EC & DEV_8176 & CC_028000PCI\VEN_10EC & DEV_8176 & CC_0280 PCI device: PCI\VE

  • Crypto pki Server missing option "info".

    After upgraging to IOS c2800nm-advsecurityk9 - mz.151 - 2.T1.bin, option requests information Server CA cryptographic pki no longer exist, the serv crypto pki CA-SERVER command is available, but only with the following options. CA #crypto CA-SERVER p

  • Wireless and LAN problem with Thinkpad

    Im having serious problems with my Thinkpad T61p on my wireless and LAN drivers (at least I think it is the drivers, could be something else). This can be a long explanation, but please bear with me. Yesterday, after seeing an example on the net, I t