Indivual error recording in Merge Statement !!!!

Is it possible to record indivudual error in MERGE statement (Update / Insert).
I am unable to record those error. instead of MERGE if I update table in the cursor loop then I am able to record individual error but the process is time consuming.
Thanks in advance.
Deba

Hi Deba,
DML Error Logging:
SQL> create table tab1 (x number(1));
Table created.
SQL> exec dbms_errlog.create_error_log('tab1')
PL/SQL procedure successfully completed.
SQL>
SQL> merge into tab1 t
  2        using (select 1 x from dual union all
  3               select 112 x from dual) s
  4  on (t.x = s.x)
  5  when not matched
  6  then insert (x) values (s.x)
  7  log errors into err$_tab1 reject limit unlimited;
1 row merged.
SQL>
SQL> COL x for 9999
SQL> select * from tab1;
    X
    1
SQL> COL x for a4
SQL> select ora_err_number$, X from err$_tab1;
ORA_ERR_NUMBER$ X
           1438 112
SQL>Regards
Peter

Similar Messages

  • Oracle 9.2i - Log Errors in a Merge Statement

    Hi all,
    I want to log errors in a merge statement in way to allow the statement to finish without rollback. I see that in Oracle 10g2 it is possible with "LOG ERRORS INTO err$_dest ('MERGE') REJECT LIMIT UNLIMITED;" instruction but, apparently, it's not possible in Oracle 9.2i.
    Is there another way to solve this problem?

    Depending on what type of errors you expect, you may be helped by deferring your constraints: unique, foreign key and check constraints can be deferred; that means they are only enforced when you commit.
    You could defer all constraints, perform the bulk insert and then instead of committing you first try to set all constraints to immediate. If this fails, there are errors. If it does not, you can commit.
    To find the exact errors, you can try to switch all deferred constraints back to immediate one by one. The ones that succeed are not violated by your transaction, oinly the ones that fail to switch to immediate are not met by your transaction.
    For the violated constraints, you can find the offending records by simply selecting them. For example if the check constraint states Col X + Col Y < 10000 you will find the offending records by selecting all records where not (Col X + Col Y < 10000 ). Unfortunately we have no better mechanism than this for finding the records that are in violation of the rules.
    best regards
    Lucas

  • Error logging in merge statement

    how to handle error logging in merge statement??
    thanks in advance!!!

    Welcome to the forum!
    Whenever you post please provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    how to handle error logging in merge statement??
    >
    Do it the way the documentation tells you to.
    See the error_logging_clause of the MERGE statement in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm
    It contains an example of using error logging with MERGE
    >
    error_logging_clause
    The error_logging_clause has the same behavior in a MERGE statement as in an INSERT statement. Refer to the INSERT statement error_logging_clause for more information.
    See Also:
    "Inserting Into a Table with Error Logging: Example"

  • 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

  • Can you explain this error message with MERGE statement

    Here is the code that gives me headache.
    I give you the description of the two tables involved and the error message I get when I run a simple MERGE statement
    SQL> desc employees
    Name Null? Type
    EMPLOYEE_ID NOT NULL NUMBER(6)
    FIRST_NAME VARCHAR2(20)
    LAST_NAME NOT NULL VARCHAR2(25)
    EMAIL NOT NULL VARCHAR2(25)
    PHONE_NUMBER VARCHAR2(20)
    HIRE_DATE NOT NULL DATE
    JOB_ID NOT NULL VARCHAR2(10)
    SALARY NUMBER(8,2)
    COMMISSION_PCT NUMBER(2,2)
    MANAGER_ID NUMBER(6)
    DEPARTMENT_ID NUMBER(4)
    SQL> desc emp2
    Name Null? Type
    EMPLOYEE_ID NOT NULL NUMBER(6)
    FIRST_NAME VARCHAR2(20)
    LAST_NAME VARCHAR2(25)
    1 MERGE INTO emp2 e2
    2 USING employees e
    3 ON (e2.employee_id = e.employee_id)
    4 WHEN MATCHED THEN
    5 UPDATE SET
    6 e2.employee_id = e.employee_id,
    7 e2.last_name = e.last_name,
    8 e2.first_name = e.first_name
    9 WHEN NOT MATCHED THEN
    10 INSERT VALUES
    11 (e.employee_id,
    12 e.last_name,
    13* e.first_name)
    14 /
    ON (e2.employee_id = e.employee_id)
    ERROR at line 3:
    ORA-00904: "E2"."EMPLOYEE_ID": invalid identifier
    Any responce much appreciated

    Hi,
    Columns going to be updated should not be in 'ON clause' , try to delete the line 6 of your query. By the way, there isno sense to update e2.employee_id = e.employee_id when matched, the equality is already verified.
    Nicolas.

  • ORA 900 error while executing MERGE statement

    Hi All,
    I am using Oracle 11 Rg1.
    I have a summarization process running daily where the process of execution is as follows:-
    1. Data loads every 10 min into a transaction table from external dat files
    2. I have a package with 13 stored procedures - each procedure has a MERGE logic to summarize data from the above table into a summarization table. Each procedure select data depending on the business requirement
    3. A wrapper file is invoked by a crontab daily to execute each procedue in the above package sequentially
    4. Each of the 13 procs is executed and data summarized daily into the summarization tables
    From a few days, I have been getting a strange error - where 5 of the stored procs are failing with the error code and description as ORA 900 - invalid sql statement. The structure of all the 13 procs is the same. The only difference is in the MERGE logic WHERE clauses.
    Due to some data loss occurence I introduced conditions the WHERE clause that take into account pl/sql variables.
    I shall paste one procedure here and provide additional details as the discussion progress to avoid making this first post very lengthy.
    This logic is failing with ORA 900 when invoked from the wrapper in unix as :-
    exec PKG_ODS_AV_SUMMARY.SP_LOAD_ODS_AV_SUMMARY_BYSRCCD(sysdate-1,'');
    create or replace PACKAGE PKG_AV_SUMMARY AS
      PROCEDURE SP_LOAD_SUMMARY_BYSRCCD (pv_sum_enddate IN DATE, pv_summm_type_indicator IN VARCHAR2);
    END PKG_AV_SUMMARY;
    create or replace
    PACKAGE BODY PKG_AV_SUMMARY AS
    --Girish:07June2011 global variables
    -- Declaring package variables to hold common constant values
    c_status_inprogress VARCHAR2(50) := PKG_SUMMARY_COMMON.FN_GET_CONSTANTVALUE('SUMMARIZATION','ODSSUMMARYPARAMETERSSTATUS_INPROGRESS');
    c_status_success VARCHAR2(50) := PKG_SUMMARY_COMMON.FN_GET_CONSTANTVALUE('SUMMARIZATION','ODSSUMMARYPARAMETERSSTATUS_SUCCESS');
    c_status_failure VARCHAR2(50) := PKG_SUMMARY_COMMON.FN_GET_CONSTANTVALUE('SUMMARIZATION','ODSSUMMARYPARAMETERSSTATUS_FAILURE');
    c_summaryType_fullLoad VARCHAR2(50) := PKG_SUMMARY_COMMON.FN_GET_CONSTANTVALUE('SUMMARIZATION','ODSSUMMARYPARAMETERSSUMMTYPE_FULL');
    c_summaryType_incrementLoad VARCHAR2(50) := PKG_SUMMARY_COMMON.FN_GET_CONSTANTVALUE('SUMMARIZATION','ODSSUMMARYPARAMETERSSUMMTYPE_INCR');
    c_errordesc_summparamisN VARCHAR2(100) := PKG_SUMMARY_COMMON.FN_GET_CONSTANTVALUE('SUMMARIZATION','ODSSUMMARYPARAMETERSERRORDESC_SUMMPARAMISN');
    PROCEDURE SP_LOAD_SUMMARY_BYSRCCD (pv_sum_enddate IN DATE, pv_summm_type_indicator IN VARCHAR2)
    AS
    lv_table_name VARCHAR2(30) := 'AV_SUMMARY_BYSRCCD';
    ln_count NUMBER;
    lv_summarizationrequired VARCHAR2(2);
    lv_summm_type_indicator VARCHAR2(5);
    lv_sum_startdate DATE;
    lv_sum_enddate DATE;
    lv_partitioned_start_date DATE;
    lv_partitioned_end_date DATE;
    ln_errorcode NUMBER;
    lv_errormsg VARCHAR2(200);
    e_exception exception;
    BEGIN
    -- lv_summm_type_indicator is used as IN OUT parameter for SP_INS_SUMMARY_PARAMETERS procedure.
    lv_summm_type_indicator := pv_summm_type_indicator;
    PKG_SUMMARY_COMMON.SP_INS_SUMMARY_PARAMETERS(lv_table_name, pv_sum_enddate, lv_summm_type_indicator,
    lv_sum_startdate, lv_sum_enddate, ln_errorcode, lv_errormsg);
    --raise e_exception;
    IF ( lv_errormsg IS NOT NULL or LENGTH(lv_errormsg) <> 0 ) THEN
         raise e_exception;
    END IF;
    lv_summarizationrequired := PKG_SUMMARY_COMMON.FN_fetch_summarizationRequired(lv_table_name);
    IF( lv_summarizationrequired = 'Y' ) THEN
    BEGIN
    IF( lv_summm_type_indicator = c_summaryType_fullLoad) THEN
    PKG_SUMMARY_COMMON.SP_FETCH_PARTITION_DATE('ARTICLE_VIEWS',lv_sum_startdate,lv_sum_enddate,lv_partitioned_start_date,lv_partitioned_end_date);
    ELSE
    lv_partitioned_start_date := lv_sum_startdate;
    lv_partitioned_end_date := lv_sum_enddate;
    END IF;
    MERGE INTO av_summary_bysrccd
    USING
    (SELECT LAST_DAY(TRUNC(to_timestamp(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS SUMMARY_DATE,
    os.acctnum,
    ol.sourcecode AS sourcecode,
    ol.sourcename AS sourcename,
    count(1) cnt_articleview
    FROM article_views os , master_sourcecode ol
    where os.sourcecode = ol.sourcecode
    AND os.acctnum IS NOT NULL
    AND ol.sourcecode IS NOT NULL
    AND os.requestdatetime IS NOT NULL
    AND UPPER(os.success_ind) = 'S'
         AND (
              (lv_summm_type_indicator  = c_summaryType_fullLoad
              AND  (get_date_timestamp(os.requestdatetime) BETWEEN lv_sum_startdate AND lv_sum_enddate
              AND   os.entry_CreatedDate BETWEEN lv_partitioned_start_date AND lv_partitioned_end_date
              OR (lv_summm_type_indicator = c_summaryType_incrementLoad
              AND os.entry_createddate BETWEEN lv_sum_startdate AND lv_sum_enddate )
    group by LAST_DAY(TRUNC(to_timestamp(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))),
    os.acctnum,ol.sourcecode,ol.sourcename) mrg_query
    ON (av_summary_bysrccd.acctnum = mrg_query.acctnum AND
    av_summary_bysrccd.summary_date=mrg_query.summary_date AND
    av_summary_bysrccd.sourcecode=mrg_query.sourcecode)
    WHEN NOT MATCHED THEN
    INSERT (SUMMARY_date,ACCTNUM,SOURCECODE,SOURCENAME,CNT_ARTICLEVIEW,ENTRY_LASTUPDATEDDATE)
    VALUES(mrg_query.summary_date,mrg_query.acctnum,mrg_query.sourcecode,mrg_query.sourcename,
    mrg_query.cnt_articleview,sysdate)
    WHEN MATCHED THEN
    UPDATE SET ods_av_summary_bysrccd.cnt_articleview=
    CASE WHEN NVL(lv_summm_type_indicator,c_summaryType_incrementLoad) = c_summaryType_fullLoad THEN mrg_query.cnt_articleview
    ELSE av_summary_bysrccd.cnt_articleview+mrg_query.cnt_articleview
    END,
    av_summary_bysrccd.entry_lastupdateddate=sysdate;
    PKG_SUMMARY_COMMON.SP_UPD_SUMMARY_PARAMETERS(lv_table_name,c_status_inprogress,c_status_success,'');
    END;
    ELSE
    PKG_SUMMARY_COMMON.SP_UPD_SUMMARY_PARAMETERS(lv_table_name,c_status_inprogress,c_status_failure,c_errordesc_summparamisN);
    END IF;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    BEGIN
    ROLLBACK;
    lv_errormsg := SQLERRM;
    ln_errorcode := SQLCODE;
    ln_count := PKG_SUMMARY_COMMON.FN_GET_COUNTOFTABLEINSUMMPARAM(lv_table_name,c_status_inprogress);
    IF ( ln_count <> 0 ) THEN
    PKG_SUMMARY_COMMON.SP_UPD_SUMMARY_PARAMETERS(lv_table_name,c_status_inprogress,c_status_failure,lv_errormsg);
    END IF;
    COMMIT;
    raise_application_error(-20004,lv_errormsg);
    END;
    END SP_LOAD_SUMMARY_BYSRCCD;
    END PKG_AV_SUMMARY;Edited by: Chaitanya on Aug 29, 2011 1:56 AM
    Edited by: Chaitanya on Aug 29, 2011 2:06 AM

    Hi Sven,
    Unfortunately, requestdatetime is a varchar2 column. The source table which has this column had been created a long back and recently we have started to take care of this issue by loading data after converting it into date format.
    We have managed to locate the place in the logic where the error is occuring, but not why it might be occuring. Its due to the logic:-
         AND (
              (lv_summm_type_indicator  = c_summaryType_fullLoad
              AND  (get_date_timestamp(os.requestdatetime) BETWEEN lv_sum_startdate AND lv_sum_enddate
              AND   os.entry_CreatedDate BETWEEN lv_partitioned_start_date AND lv_partitioned_end_date
              OR (lv_summm_type_indicator = c_summaryType_incrementLoad
              AND os.entry_createddate BETWEEN lv_sum_startdate AND lv_sum_enddate )
         )When I hardcoded the values for lv_summm_type_indicator, c_summaryType_fullLoad and c_summaryType_incrementLoad, the logic worked fine:
         AND (
              ('INCR'  = 'FULL'
              AND  (get_date_timestamp(os.requestdatetime) BETWEEN lv_sum_startdate AND lv_sum_enddate
              AND   os.entry_CreatedDate BETWEEN lv_partitioned_start_date AND lv_partitioned_end_date
              OR ('INCR'  = 'INCR'
              AND os.entry_createddate BETWEEN lv_sum_startdate AND lv_sum_enddate )
         )But, the data for the pl sql variables is coming properly as I used dbms_output statements to check. So not sure what exactly is happening.

  • Getting an error in MERGE statement

    Hi,
    I am getting an error "missing keyword" when I execute the MERGE statement.
    Here I have attached copy of MERGE statement which I am trying to execute.
    (My requirement is if I find matching record then insert again it's a business requirement. And if not then set flag)
    MERGE INTO t1
    USING t2
    ON (conditions)
    WHEN MATCHED THEN
    INSERT (column list from t1)
    VALUES (from t2)
    WHEN NOT MATCHED THEN
    UPDATE
    SET ... ;
    Can someone guide me?
    Thanks,

    This is why I told you yesterday in this thread...
    Need suggestion in MERGE Statement
    ...that what you're asking is the opposite of the way MERGE works.
    Guess you didn't want to believe me.

  • 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.

  • Error executing a stored procedure from SSIS using the MERGE statement between databases

    Good morning,
    I'm trying to execute from SSIS a stored procedure that compares the content of two tables on different databases in the same server and updates one of them. To perform this action, I've created a stored procedure in the destination database and I'm
    comparing the data between tables with the MERGE statement. When I execute the procedure on the destination database the error that I obtain is:
    "Msg 916, Level 14, State 1, Procedure RefreshDestinationTable, Line 13
    The server principal "XXXX" is not able to access the database "XXXX" under the current security context."
    Some things to take in account:
    1. I've created a temporary table on the same destination database to check if the problem was on the MERGE statement and it works fine.
    2. I've created the procedure with the option "WITH EXECUTE AS DBO".
    I've read that it can be a problem of permissions but I don't know if I'm executing the procedure from SSIS to which user/login I should give permissions and which.
    Could you give me some tip to continue investigating how to solve the problem?
    Thank you,
    Virgilio

    Read Erland's article http://www.sommarskog.se/grantperm.html
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • 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.

  • Error in MERGE statement - ORA-00969: missing ON keyword

    Hi All ,
    I am trying to write a Merge statement , but I am getting the below error .
       MERGE  INTO main_table m
                              USING  tab_1 l, tab_2 u
                              ON  (   l.col1        =  m.col1
                                       AND u.col2 = l.col2)
    When Matched then
    update........
    When not mached then
    Insert  ...... 
    But here I am using 2 tables in the USING clause . and here I am getting  this error :-
    142/17   PL/SQL: SQL Statement ignored
    143/42   PL/SQL: ORA-00969: missing ON keyword
    May I know where i am doing wrong ?

    Hi LuKKa, you are on the Portugues Forum, but we can help you, try the code mentioned below:
       MERGE  INTO main_table m
                              USING  (select l.col1, l.col2, u.col2 from tab_1 l join tab_2 u on (u.col2 = l.col2)) t
                              ON  (t.col1 =  m.col1)
    When Matched then
    update........
    When not mached then
    Insert  ......  
    Regards.

  • Invalid Number Error in Merge Statement

    Hi all.
    I got an invalid number error in the following merge statement, but I don't know why. Maybe you can give me a hint.
    MERGE INTO wam_table
    USING (SELECT * FROM wam_table) b
    ON (b.username = 'user'
    AND b.mod = 'module'
    AND b.trimester = '1')
    WHEN MATCHED THEN
    UPDATE SET as = '1', ad = '1', co = '1', pr = '1', date = localtimestamp, lus = 'username'
    WHEN NOT MATCHED THEN
    INSERT VALUES ('user','module','1','1','1','1','1', localtimestamp, 'username');
    The invalid number error appears in the first line, but I don't know why?
    Stephan

    UPDATE SET as = '1', ad = '1', co = '1', pr = '1', date = localtimestamp, lus = 'username'SELECT * FROM sys.v_$reserved_words;
    SQL> create table test1(as varchar2(10));
    create table test1(as varchar2(10))
    ERROR at line 1:
    ORA-00904: : invalid identifier
    SQL> create table test1(sno number, date date);
    create table test1(sno number, date date)
    ERROR at line 1:
    ORA-00904: : invalid identifier
    SQL> create table test1("as" varchar2(10));
    Table created.
    SQL>
    SQL> create table test2(sno number, "date" date);
    Table created.
    SQL> desc test1
    Name                                      Null?    Type
    as                                                 VARCHAR2(10)
    SQL> desc test2
    Name                                      Null?    Type
    SNO                                                NUMBER
    date                                               DATE
    SQL> 

  • Error in Merge statement for Oracle 10gR2

    Hi,
    When I use the MERGE statement to copy data across a database link (from 10gR2 to 10gR2 database), if I have both an update and insert clause it works fine, but if I omit the insert clause and have just update on its own, I get error "ORA-02064: distributed operation not supported".
    Can anyone help on this

    This came up in a thread last week, the 10g versions of MERGE (without INSERT or with DELETE) did not appear to work over DB links.

  • Urgent..Merge statement error

    Hi,
    I need help to resolve my Merge Statement problem.
    This one is sample code.
    l_str := ' Merge ....' ||
    ' where comp = :l_comp ';
    execute immediate l_str using l_comp;
    as soon as this statement executed..it throws me an error:
    ORA-01008: not all variables bound
    Could you please help me?
    Thanks in advance.
    RD

    I've few things to say. Please remove the word URGENT. Otherwise, you may have some problem here. The reason why i'm saying is that - every one has their own job. So, better - if you remove this word. Don't take it otherwise.
    Coming to your problem - it is very difficult to tell from this code that you have given. Please post the full script that will help us to track down the problem. Initially, i think you should check your bind varibles. Whether you declare it properly or not.
    Regards.
    Satyaki De.

  • 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

Maybe you are looking for