Where should use Merge Statement in Form

hi experts
in Toad I am using this Merge statement , working accordingly.
I want to use this merge statement in my form where can I use it.
I created a Procedure in Form Named Proc_merge and call it when validate item of *:bankcode*
PROCEDURE proc_merge IS
BEGIN
declare
v_com varchar2(5000);
BEGIN
V_COM := ' 
Merge into allvouchers trg
using
(select voucher_type,voucher_no,voucher_date,cheque_no,bank_code,narration,debit,credit from(
select pv_voucher_type Voucher_type, pv_no Voucher_No, pv_date Voucher_date, Cheque_no, Acc_code Bank_code, Narration,Debit,Credit 
from
                    (select a.pv_voucher_type,a.pv_no, a.pv_date, a.cheque_no, a.pv_gl_credit_code acc_code , b.ca_title,null Debit,
                                a.pv_gl_credit_amount Credit, a.Pv_narration Narration
                               from gl_pv a, ca_gl b where a.pv_gl_credit_Code = b.ca_code and a.pv_date > to_date (''30/06/2010'',''dd/mm/yyyy'')  
union all 
                    select  a.pv_voucher_type,a.pv_voucher_no,a.pv_date,b.cheque_no,a.pv_acc_code,c.ca_title,a.pv_debit, Null credit,a.pv_desc
                    from payment_detail a, gl_pv b, ca_gl c
                    where a.pv_voucher_no = b.pv_no
                    and a.pv_date = b.pv_date
                    and a.pv_voucher_type = b.pv_voucher_type 
                    and pv_acc_code = c.ca_code and a.pv_debit > 0
                    and a.pv_date > to_date (''30/06/2010'',''dd/mm/yyyy'')     
union all
                        select  a.pv_voucher_type, a.pv_voucher_no,a.pv_date, b.cheque_no, a.pv_acc_code, c.ca_title,
                    null ,a.pv_credit, a.pv_desc
                    from payment_detail a , gl_pv b , ca_gl c
                    where a.pv_voucher_no = b.pv_no
                    and a.pv_date = b.pv_date
                    and a.pv_acc_code = c.ca_code
                    and pv_credit >0 and a.pv_date > to_date (''30/06/2010'',''dd/mm/yyyy'')
union all
                    select  a.pv_voucher_type, a.pv_no,pv_date,a.cheque_no , a.wht_debt_ac, b.ca_title , null, a.wht_amount, a.wht_narration 
                    from gl_pv a , ca_gl b where  a.wht_debt_ac = b.ca_code and  wht_amount > 0
                    and a.pv_date > to_date (''30/06/2010'',''dd/mm/yyyy'')
                    where acc_code = :bankcode
                    Union all 
---------------------   R.Voucher ----------------
select a.rv_voucher_type, a.rv_no, a.rv_date, a.chequeno, b.rv_acc_code, a.rv_narration,b.rv_debit, b.rv_credit
from gl_receipt a, receipt_detail b , ca_gl c
          where a.rv_no = b.rv_voucher_no
          and a.rv_date = b.rv_date
          and b.rv_acc_code = c.ca_code
          and b.rv_acc_code = :bankcode
          and a.rv_date > to_date (''30/06/2010'',''dd/mm/yyyy'')
----------------------- SRV --------------
Union all
select  a.vm_voucher_type ,a.vm_no ,a.vm_date,a.chequeno,b.vd_acc_code, b.vd_desc VNARRAION,
          b.vd_debit VDEBIT,b.vd_credit VCREDIT           
          from vouchermaster a, voucherdetail b , ca_gl c
          where a.vm_no= b.vd_no
          and a.vm_voucher_type = b.vm_voucher_type
          and a.vm_date = b.vm_date
          and b.vd_acc_code = c.ca_code
          and b.vd_acc_code  = :bankcode
          and a.vm_date > to_date (''30/06/2010'',''dd/mm/yyyy'')  
          and (a.show_voucher =''Y'' or Show_Voucher is Null)
          and a.vm_voucher_type =''SRV''
          )) Src
on (trg.v_type = src.voucher_type and trg.v_no = src.voucher_no and trg.v_date = src.voucher_date)
when matched then
update set
trg.v_chq = src.cheque_no, trg.v_bankcode = src.bank_code ,trg.v_debit=src.debit, trg.v_credit=src.credit, trg.v_narration=src.narration
when not matched then
insert (trg.v_type, trg.v_no, trg.v_date, trg.v_chq, trg.v_bankcode, trg.v_debit, trg.v_credit, trg.v_narration)
values (src.voucher_type, src.voucher_no, src.voucher_date, src.cheque_no, src.bank_code, src.debit, src.credit, src.narration)      
FORMS_DDL(V_COM);
end;
END;no any result.
please guide me is this right way to do this. or kindly suggest me other ways to using merge statement in form.

Hello,
1.) why do you use dynamic SQL here? forms_ddl is a tricky one as it doesn't throw exceptions, so debugging is really fun. And I can't see any justification why this has to be dynamic SQL.
2.) put the whole thing in a stored procedure and call this procedure. write once, run everywhere.
cheers

Similar Messages

  • Error while using Merge statement

    Hi,
    Can any one please look at the merge statement and help me understand the error.Thanks in advance.
    MERGE /*+ APPEND */
    INTO intf_lpa_master m
    USING (SELECT std_district_student_id,
    std_grade_code,
    sub_test,
    test_date,
    performance_lvl_code,
    test_lang_code,
    v_student_id,
    v_test_id,
    v_lang_cd,
    v_plc,
    valid_test_date,
    -- school_year,
    -- school_id,
    valid_src_stu_id,
    test_code
    FROM intf_lpa_master_vw
    MINUS
    SELECT std_district_student_id,
    std_grade_code,
    sub_test,
    test_date,
    performance_lvl_code,
    test_lang_code,
    v_student_id,
    v_test_id,
    v_lang_cd,
    v_plc,
    valid_test_date,
    -- school_yr,
    -- school_id,
    valid_src_stu_id,
    test_code
    FROM intf_lpa_master
    WHERE active_flag = 'Y') v
    ON ( m.std_district_student_id = v.std_district_student_id
    AND m.sub_test = v.sub_test
    AND m.test_date = v.test_date)
    WHEN MATCHED
    THEN
    UPDATE SET m.std_grade_code = v.std_grade_code,
    m.performance_lvl_code = v.performance_lvl_code,
    m.test_lang_code = v.test_lang_code,
    m.active_flag = 'Y', -- if we are touching this record, it is to be active.
    m.error_message = NULL, -- refresh these, to properly reconsider records.
    m.create_date = SYSDATE,
    m.record_id = intf_lpa_master_seq.NEXTVAL,
    m.process_row = 'U',
    m.last_update_date = SYSDATE,
    m.last_update_user = 'PRE_PROCESS_LPA - UPDATE',
    -- m.job_id = c_run_id ,
    m.validation_step = NULL, -- refresh these, to properly reconsider records.
    m.v_student_id = v.v_student_id,
    m.v_test_id = v.v_test_id,
    m.v_lang_cd = v.v_lang_cd,
    m.v_plc = v.v_plc,
    m.valid_test_date = v.valid_test_date,
    -- m.school_year = v.schloo_year,
    -- m.school_id = v.school_id,
    m.valid_src_stu_id = v.valid_src_stu_id,
    m.test_code = v.test_code
    WHEN NOT MATCHED
    THEN
    INSERT (
    m.std_district_student_id,
    m.std_grade_code,
    m.sub_test,
    m.test_date,
    m.performance_lvl_code,
    m.test_lang_code,
    m.active_flag,
    m.error_message,
    m.create_date,
    m.record_id,
    m.process_row,
    m.last_update_date,
    m.last_update_user,
    -- m.job_id,
    m.validation_step,
    m.v_student_id,
    m.v_test_id,
    m.v_lang_cd,
    m.v_plc,
    m.valid_test_date,
    -- m. school_year,
    -- m. school_id,
    m.valid_src_stu_id,
    m.test_code)
    VALUES (
    v.std_district_student_id,
    v.std_grade_code,
    v.sub_test,
    v.test_date,
    v.performance_lvl_code,
    v.test_lang_code,
    'Y',
    NULL,
    SYSDATE,
    intf_lpa_master_seq.NEXTVAL,
    'I',
    SYSDATE,
    'PRE_PROCESS_LPA - INSERT',
    -- c_run_id,
    NULL,
    v.v_student_id,
    v.v_test_id,
    v.v_lang_cd,
    v.v_plc,
    v.valid_test_date,
    -- v. school_year,
    -- v. school_id,
    v.valid_src_stut_id,
    v.test_code);
    Error Message :
    ORA-06553 : PLS-306:wrong number or types of arguments in call to 'V'

    There are a couple of thngs wrong here. In the when matched insert column list, you cannot qualify the field name with the table alias. It should be just:
    insert (std_district_student_id, std_grade_code, sub_test ...)Are v_student_id, v_test_id, v_lang_cd, and v_plc really columns in the intf_lpa_master table? I am more used to seeing v_name as a variable naming convention than a column name, but I could be wrong.
    John

  • Help needed in MERGE statement

    Hi,
    I am new to PL/SQL, I want to update a table called "final_test" based on the below query result.
    1. I want to check whether that particular record is present or not in my "final_test" table.
    2. If its present in the "final_test" table and the process_status got changed then I want to update that alone in my "final_test" table.
    3. If its not present then I want to insert that record into my "final_test" table.
    Basically I am retrieving the report and its status for a particular date.
    select
    b.id,
    a.name,
    a.t_name,
    c.process_status,
    c.time_process
    from rep_tab_map a, j_tab_map b, proc_status c
    where a.t_name=b.t_name
    and b.id=c.id (+)
    and trunc(c.date_start)=trunc(sysdate -1)
    group by a.name,b.id,c.process_status,c.time_process,a.t_name
    order by 2
    I thought of using Merge statement but i am not sure what i have to use in ":USING" and "ON" clause.
    Please help me with MERGE or with someother way.
    Thanks

    Assuming final_test has same structure as select list in your query:
    merge
      into final_test a
      using (
             select  b.id,
                     a.name,
                     a.t_name,
                     c.process_status,
                     c.time_process
               from  rep_tab_map a,
                     j_tab_map b,
                     proc_status c
               where a.t_name=b.t_name
                 and b.id=c.id(+)
                 and trunc(c.date_start)=trunc(sysdate -1)
               group by a.name,b.id,c.process_status,c.time_process,a.t_name
            ) b
      on (b.id = a.id)
      when matched then update set a.name = case a.process_status
                                              when b.process_status then a.name
                                              else b.name
                                            end,
                                   a.t_name = case a.process_status
                                                when b.process_status then a.t_name
                                                else b.t_name
                                              end,
                                   a.process_status = b.process_status,
                                   a.time_process = case a.process_status
                                                      when b.process_status then a.time_process
                                                      else b.time_process
                                                    end
      when not matched then insert(
                                   a.id,
                                   a.name,
                                   a.t_name,
                                   a.process_status,
                                   a.time_process
                            values(
                                   b.id,
                                   b.name,
                                   b.t_name,
                                   b.process_status,
                                   b.time_process
    /SY.

  • Problem in Merge statement

    Hi All,
    I am using merge statement to update 30000 records from the tables having 55 lacs records.
    But it is taking much time as i have to kill the session after 12 hours,as it was still going on.
    If,Same update i m doing using cursors,it will finish in less than 3 hours.
    Merge i was using is :-
    MERGE INTO Table1 a
    USING (SELECT MAX (TO_DATE ( TO_CHAR (contact_date, 'dd/mm/yyyy')
    || contact_time,
    'dd/mm/yyyy HH24:Mi:SS'
    ) m_condate,
    appl_id
    FROM Table2 b,
    (SELECT DISTINCT acc_no acc_no
    FROM Table3, Table1
    WHERE acc_no=appl_id AND delinquent_flag= 'Y'
    AND financier_id='NEWACLOS') d
    WHERE d.acc_no = b.appl_id
    AND ( contacted_by IS NOT NULL
    OR followup_branch_code IS NOT NULL
    GROUP BY appl_id) c
    ON (a.appl_id = c.appl_id AND a.delinquent_flag = 'Y')
    WHEN MATCHED THEN
    UPDATE
    SET last_contact_date = c.m_condate;
    In this query table 1 has 30000 records and table2 and table 3 have 3670955 and 555674 records respectively.
    Please suggest,what i am doing wrong in merge,because as per my understanding merge statement is much better than updates or updates using cursors.
    Required info is as follows:
    SQL> show parameter user_dump_dest
    NAME TYPE VALUE
    user_dump_dest string /opt/oracle/admin/FINCLUAT/udu
    mp
    SQL> show parameter optimizer
    NAME TYPE VALUE
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 10.2.0.4
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean TRUE
    SQL> show parameter db_file_multi
    NAME TYPE VALUE
    db_file_multiblock_read_count integer 16
    SQL> show parameter db_block_size
    NAME TYPE VALUE
    db_block_size integer 8192
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> select
    2 sname     ,
    3 pname     ,
    4 pval1     ,
    5 pval2
    6 from
    7 sys.aux_stats$;
    sys.aux_stats$
    ERROR at line 7:
    ORA-00942: table or view does not exist
    Elapsed: 00:00:00.05
    SQL> explain plan for
    2 -- put your statement here
    3 MERGE INTO cs_case_info a
    4      USING (SELECT MAX (TO_DATE ( TO_CHAR (contact_date, 'dd/mm/yyyy')
    5                          || contact_time,
    6                          'dd/mm/yyyy HH24:Mi:SS'
    7                          )
    8                ) m_condate,
    9                appl_id
    10           FROM CS_CASE_DETAILS_ACLOS b,
    11                (SELECT DISTINCT acc_no acc_no
    12                FROM NEWACLOS_RESEARCH_HIST_AYLA, cs_case_info
    13                WHERE acc_no=appl_id AND delinquent_flag= 'Y'
    14                AND financier_id='NEWACLOS') d
    15           WHERE d.acc_no = b.appl_id
    16           AND ( contacted_by IS NOT NULL
    17                OR followup_branch_code IS NOT NULL
    18                )
    19           GROUP BY appl_id) c
    20      ON (a.appl_id = c.appl_id AND a.delinquent_flag = 'Y')
    21      WHEN MATCHED THEN
    22      UPDATE
    23           SET last_contact_date = c.m_condate
    24      ;
    Explained.
    Elapsed: 00:00:00.08
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
    | 0 | MERGE STATEMENT | | 47156 | 874K| | 128K (1)|
    | 1 | MERGE | CS_CASE_INFO | | | | |
    | 2 | VIEW | | | | | |
    | 3 | HASH JOIN | | 47156 | 36M| 5672K| 128K (1)|
    | 4 | VIEW | | 47156 | 5111K| | 82339 (1)|
    | 5 | SORT GROUP BY | | 47156 | 4236K| 298M| 82339 (1)|
    | 6 | HASH JOIN | | 2820K| 247M| 10M| 60621 (1)|
    | 7 | HASH JOIN | | 216K| 7830K| | 6985 (1)|
    | 8 | VIEW | index$_join$_012 | 11033 | 258K| | 1583 (1)|
    | 9 | HASH JOIN | | | | | |
    | 10 | INDEX RANGE SCAN | IDX_CCI_DEL | 11033 | 258K| | 768 (1)|
    | 11 | INDEX RANGE SCAN | CS_CASE_INFO_UK | 11033 | 258K| | 821 (1)|
    | 12 | INDEX FAST FULL SCAN| IDX_NACL_RSH_ACC_NO | 5539K| 68M| | 5382 (1)|
    | 13 | TABLE ACCESS FULL | CS_CASE_DETAILS_ACLOS | 3670K| 192M| | 41477 (1)|
    | 14 | TABLE ACCESS FULL | CS_CASE_INFO | 304K| 205M| | 35975 (1)|
    Note
    - 'PLAN_TABLE' is old version
    24 rows selected.
    Elapsed: 00:00:01.04
    SQL> rollback;
    Rollback complete.
    Elapsed: 00:00:00.03
    SQL> set autotrace traceonly arraysize 100
    SQL> alter session set events '10046 trace name context forever, level 8';
    ERROR:
    ORA-01031: insufficient privileges
    Elapsed: 00:00:00.04
    SQL>      disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>      spool off
    Edited by: user4528984 on May 5, 2009 10:37 PM

    For one thing, alias your tables and use that in the column specifications (table1.column1 = table2.column3 for example)...
          SELECT
             DISTINCT
                acc_no acc_no
          FROM Table3, Table1
          WHERE acc_no            = appl_id
          AND   delinquent_flag   = 'Y'
          AND   financier_id      = 'NEWACLOS'We don't know what your tables look like, what columns come from where. Try and help us help you, assume we know NOTHING about YOUR system, because more likely than naught, that's going to be the case.
    In addition to that, please read through this which will give you a better-er idea of how to post a tuning related question, you've not provided near enough information for us to intelligently help you.
    HOW TO: Post a SQL statement tuning request - template posting

  • Merge Statement Giving Error

    Hi Everyone,
    I am trying to use MERGE statement for my Data Load. But it is giving out an un-understandable error. It In the "ON" Part, it refuses to recognise the destination table columns...
    like I say ON(dest.Per_No = Src.Per_No), and it says "Invalid Identifier dest.Per_No"
    Any Ideas, am pasting shortened version of my SQL:
    ========================================
    SQL> ed
    Wrote file afiedt.buf
    1 MERGE INTO CIPIC.Dest P
    2 USING (SELECT Src1.ROW_ID AS PER_No,
    3 LTRIM(Src2.PARTY_ID,'0') AS ARN,
    4 ....
    9 FROM Src1,Src2,....
    12 WHERE MANY JOINS GO HERE) S
    16 ON (P.PER_No = S.PER_No AND P.A_Column = S.A_Column)
    17 WHEN MATCHED THEN UPDATE SET P.blah = S.blah1
    24 WHEN NOT MATCHED THEN INSERT (PER_No, A_Column,....)
    26 VALUES (S.PER_No, .A_Column, ......)
    SQL> /
    ON (P.PER_No = S.PER_No AND P.A_Column = S.A_Column)
    ERROR at line 16:
    ORA-00904: "P"."PER_No": invalid identifier

    See here
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#2080942
    >
    Restrictions on Updating a View
    You cannot specify DEFAULT when updating a view.
    You cannot update a column that is referenced in the ON condition clause.
    Rgds.

  • Doubt Regarding Merge Statement in Oracle

    Hi,
    I have an SP which takes 3 parameters Lets say
    (in_empid, in_empname,in_age)
    here in_empid corresponds to the empid ie primary key for update/insert
    Now which of the approach will be better. Will there be problem in using Merge statements for updates/insert
    1. Approach 1
    Add one more flag in parameters in_action . Now if in_action = 'U' then write an update statement.If in_action='I' then write insert stmnt
    2. Approach 2
    write a merge stmnt as follows
    merge into employee e using
    ( select in_empid, in_empname,in_age from dual ) b
    on  ( b.in_empid = e.empid)
    WHEN MATCHED THEN
      UPDATE SET e.ENAME = in_empname,
                           e.age = in_age
    WHEN NOT MATCHED THEN
      INSERT
      VALUES (in_empid,in_empname,in_age) something like that
    Which would be preferred? I mean is there any restriction that merge can be used only to merge 2 tables?what are the drawbacks of using Merge?
    Regds,
    S

    Hi cd,
    Thanks for the reply.
    Actaully I was keeping the front-end code also in mind.
    If we click an update button, then they will have to manage a flag till the end to say that transaction was update. whereas when its an insert of new record, they have to maintain a falg till end to imply that the transaction was insert.
    I want to avoid this so that they need not maintain additional flag.
    Hence I was thinking of using MERGE statement.
    Will there be any problem in using merge for such scenarios?
    Regds,
    S

  • XML insertion/updation using merge and generate sequence number

    Hi,
    I am working on Oracle 11g.
    I have a doubt with XML load.
    I get an xml and I have to insert or update data into a table A. This I can achieve using MERGE statement.
    But there is one column in Table A, that I need to populate with a sequence number, based on the data sent in the xml.
    The xml does not send this column data.
    And I have to make sure the sequence is created based on the order in which records are present in xml.
    For example the MERGE is inserting five rows and then updating next two rows and again inserting 3 rows from xml into table A. The sequence number should be created in the same order for the column in table A.
    Also for each new xml, the sequence starts with 1 and ends with the number of records in the xml. So I cannot create a sequence and use seq.nextval.
    Please let me know, there is a way of achieveing this.
    Thank you!
    Edited by: 934451 on Aug 8, 2012 6:33 AM
    Edited by: 934451 on Aug 8, 2012 6:50 AM

    Hi,
    Following up on your previous thread : {thread:id=2403469}
    You can use the FOR ORDINALITY clause in XMLTable to generate the required sequence :
    MERGE INTO target_table t
    USING (
      SELECT x.seq_num, x.pk_id, x.col1, x.col2, ...
      FROM XMLTable(
             '/root/record'
             passing my_xml_doc
             columns seq_num FOR ORDINALITY
                   , pk_id   number       path 'ID'
                   , col1    varchar2(30) path 'COL1'
                   , col2    varchar2(30) path 'COL2'
           ) x
    ) src
    ON ( t.pk_id = src.pk_id )
    WHEN MATCHED THEN UPDATE
    SET t.seq_num = src.seq_num
       , t.col1 = src.col1
       , t.col2 = src.col2
    WHEN NOT MATCHED THEN INSERT
    (seq_num, pk_id, col1, col2, ...)
    VALUES (src.seq_num, src.pk_id, src.col1, src.col2, ...)
    ;

  • How to use MERGE for this scenario?

    I am using oracle 10G and i need a help on using MERGE statement based on a condition.
    I have no values in table test_tab. So the below MERGE should insert the value, but it is not inserting the record. Please corret me if anything wrong with the below Query.
    MERGE INTO test_tab t
       USING (SELECT NO
                FROM test_tab) s
       ON (s.NO = 1)
       WHEN MATCHED THEN
          UPDATE
             SET t.str = 'EXIST'
       WHEN NOT MATCHED THEN
          INSERT (t.NO, t.str)
          VALUES (1, 'NOT_EXIST');

    MERGE INTO test_tab t
       USING  test_tab s
       on (t.no = 1 )
       WHEN MATCHED THEN
          UPDATE
             SET t.str = 'EXIST'
       WHEN NOT MATCHED THEN
          INSERT (t.NO, t.str)
          VALUES (1, 'NOT_EXIST');

  • Is it possible to use MERGE with sql*plus and if yes how?

    Hello everybody,
    I have an xls file and I have to load its data with sql*loader, but instead of "APPEND" operation stated in the control file I need MERGE operation.Here is what my control file contains:
    LOAD DATA
    INFILE 'C:\WORK\DSK_WH\LOAD_FIRST\sqlldr\data.csv'
    BADFILE 'C:\WORK\DSK_WH\LOAD_FIRST\sqlldr\p_badfile.txt'
    APPEND
    INTO TABLE D_ACCOUNT_NAMES_TMP
    FIELDS TERMINATED BY ";"
    TRAILING NULLCOLS
    (account_number , consignment, sub_consignment, consign_sub_consign, account_name_bg, account_number_2, consign_parent_2, account_name_bg_2, account_number_3, account_name_bg_3, account_number_4, account_name_bg_4, account_number_5 , ACCOUNT_NAME_BG_5 ).
    How can I use merge in this case , instead of insert ?
    Regards,
    Maria

    I'm not sure if there is any MERGE thing in SQL*Loader, but you can have a backup table which gets loaded by SQL*Loader and then use MERGE statement from backup to the original table, if your data is not huge to become a performance barrier. This is just a suggestion, may be you can try some reading of SQL*Loader here.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/part2.htm#436160
    Cheers
    Sarma.

  • Help needed in the Merge Statement

    Hi All,
    I am using MERGE statement in my program. I want to maintain the log for the duplicate reords mean maintain the log for those reocrds which are updated in the merge statement.
    Can any one help me in this that how can i maintain the log?
    Thanks for your help in advance.
    kind Regards,

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:35615502072484

  • Locking in Merge Statement

    Hi All,
    I am using merge statement to insert and update rows. The merge statement takes a row level exclusive lock
    Suppose the select statement returns 1 Million records does
    1) The merge statement first tries to lock all the affected rows and then update / insert records.
    OR
    2) The merge statement aquires lock on an incremental basis as returned by the select statement.

    The merge works just like an insert or update statement in that locks are acquired "on an incremental basis", but as of the timestamp the merge began. When Oracle detects that another session has updated a row in the meantime, then it re-executes the entire merge statement as of that new timestamp. It is sometimes referred to as "write consistency".
    Here is a good Asktom thread on this topic: http://asktom.oracle.com/pls/asktom/f?p=100:11:1694097844551766::::P11_QUESTION_ID:11504247549852
    Regards,
    Rob.

  • Can u rectify the error  in merge statement in sql

    hi to all,
    i had created a duplicate table of emp with the name of copy_emp with no records.
    by using merge statement i want to update the existing rows and insert new rows into copy_emp table as follows ......
    merge into copy_emp c
    using emp e
    on(c.empno=e.empno) --------> here the error is ........ invalid column name
    when matched then
    update set c.empno=e.empno,.....
    when not matched then
    insert values(e.empno,e.job,e.sal........);

    merge into copy_emp c
    using emp e
    on(c.empno=e.empno) --------> here the error is ........ invalid column name
    when matched then
    update set c.ename=e.ename,.....
    when not matched then
    insert values(e.empno,e.job,e.sal........);
    take off empno from update clause.

  • Syntax for Merge statement to insert into target and update source

    Hello All,
    I want to use Merge statement to insert records when not matched in my target and update records in source when matched. Is it possible to do using Merge statement.
    create table a (aa number)
    create table b (bb number)
    alter table a add flg char(1)
    merge b as target
    using a as source
    on (target.bb = source.aa)
    when matched then
    update set source.flg = 'Y'
    WHEN NOT MATCHED THEN
    insert (target.bb)
    values
    (source.aa)
    Thanks.

    Hi,
    I have no idea about the version of DB, else some new features with respect version can be specified - just for informaitve purpose and to post across the verison of DB in future posts.
    Coming to your issue and requirement.
    if you check the syntax and functionality , then its on Merge on target base only - with respect to Update (matched o columns) and insert (for unmatched columns). Source - as the term is clear. It might not work out on source table.
    - Pavan Kumar N
    - ORACLE OCP - 9i/10g
    https://www.oracleinternals.blogspot.com

  • Using spry:state="loading" only after a certain interval

    Hi everyone ,
        I need a feature for spry regions. I want my loading spry state to show only loading of data takes 0.5 seconds and more.
    Is it possible with this version of spry?
    Ps1 : you can find a live example of my need in google webmaster tools' content section,content by title page. There is an ajax listview with paging on page and loading div only apeears if loading of data takes more than a certain milliseconds.
    Ps2 : Spry rulezzzz

    vw2ureg wrote:
    Hi,
    Go here and scroll down to ErrorState, LoadingState and ReadyState.
    I hope this helps.
    Ben
    That will only tell Spry that it should should use different "state" as loading state. But it doesn't display a loading state after a certain interval. This functionality does not exist in the Spry library. But you could create a custom "loading" state that you automatically trigger using setTimeout if your haven't gotten a onPostUpdate through your region observer.
    But i'm curious why you would wanna do create a have the loading state after a certain interval.

  • MERGE Statement Problem for Storing Old Data

    Hi,
    I am using MERGE statement to update as well as insert rows on ta table.
    I have a data like in a table 'TABLEA' as 10 20 30 ABCD
    I want to update the table using 10 20 30 DEFG but i want the old data i.e 10 20 30 ABCD
    to store in a History table i.e TABLEA_H.
    Is there any way to store the data
    Any help will be needful for me

    Hi,
    Trigger usage may affect the performance as we are handling Production environment.
    is there any way to implement the scenario without using Triggers?
    Any help will be needful for me

Maybe you are looking for

  • My itunes isnt working

    My app store isnt working and when ever i go on i tunes it says the certificate for this server is invalid.

  • Apple logo is it a light ?

    if it is how do i turn it on it looks like a light :P

  • How to I get lost memory back?

    I was following a step-by-step video on Youtube on how to get Arma 2 and DayZ for Mac. And I had to get VMware Fusion. After many hours, I figured it out. I got a virtual machine, Windows 7, on my Macbook Air. I had to do all this configuring and dow

  • Collage Screensaver - names and dates don't show up

    In the collage setting of Screensaver, the photo dates and names don't show up, even though I selected the option to include them. I could not figure this out, so took it to the Genius Bar. After about 20 minutes of trying this and that, he rebuilt t

  • Facebook won't load properly

    facebook no longer loads properly.  comes up with a white page