Merge statement hangs
Dear all
I am using oracle 9i(9.2.0.1.0). I have a Merge statement which inserts 14million records.
I am able to execute the merge statement in 4mins.
When i try to execute the same merge on oracle (9.2.0.6 ) with same hardware config on client machine, My merge statement hangs.
Please let me know if any patches are there and what all parameters do i need to look into to trace the problem.
Regards
Surendra
Hi
Do you have the same indexes and statistics in the two systems?
Ott Karesz
http://www.trendo-kft.hu
Similar Messages
-
i would like to know if it is possible to identify the row that is causing the problem when you use a merge statement in pl/sql. i know if you create a cursor and then loop through the data you can identify the column but what about if i have only a merge that will either insert or update. is it possible to identify which row of data cause the problem? thanks
You can use an Error Logging Table<br>
<br>
Nicolas. -
Hi
I am using a merge statement where i am updating and inserting records in table 2 from table 1.
I want to log the no. of rows updated and new rows inserted in the log table.
If i am not wrong, we can use sql%rowcount but i need help as how to use this statement.
Please suggest a solution.
Thanksuser11018028 wrote:
Will the sql%rowcount will give the no. of updated rows OR no. of newly inserted rows OR the sum of both in case of a merge statement.Total number of rows that changed (SUM). -
Question on passing string values to Partition clause in a merge statement
Hello All,
I am using the below code to update specific sub-partition data using oracle merge statements.
I am getting the sub-partition name and passing this as a string to the sub-partition clause.
The Merge statement is failing stating that the specified sub-partition does not exist. But the sub-partition do exists for the table.
We are using Oracle 11gr2 database.
Below is the code which I am using to populate the data.
declare
ln_min_batchkey PLS_INTEGER;
ln_max_batchkey PLS_INTEGER;
lv_partition_name VARCHAR2 (32767);
lv_subpartition_name VARCHAR2 (32767);
begin
FOR m1 IN ( SELECT (year_val + 1) AS year_val, year_val AS orig_year_val
FROM ( SELECT DISTINCT
TO_CHAR (batch_create_dt, 'YYYY') year_val
FROM stores_comm_mob_sub_temp
ORDER BY 1)
ORDER BY year_val)
LOOP
lv_partition_name :=
scmsa_handset_mobility_data_build.fn_get_partition_name (
p_table_name => 'STORES_COMM_MOB_SUB_INFO',
p_search_string => m1.year_val);
FOR m2
IN (SELECT DISTINCT
'M' || TO_CHAR (batch_create_dt, 'MM') AS month_val
FROM stores_comm_mob_sub_temp
WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val)
LOOP
lv_subpartition_name :=
scmsa_handset_mobility_data_build.fn_get_subpartition_name (
p_table_name => 'STORES_COMM_MOB_SUB_INFO',
p_partition_name => lv_partition_name,
p_search_string => m2.month_val);
DBMS_OUTPUT.PUT_LINE('The lv_subpartition_name => '||lv_subpartition_name||' and lv_partition_name=> '||lv_partition_name);
IF lv_subpartition_name IS NULL
THEN
DBMS_OUTPUT.PUT_LINE('INSIDE IF => '||m2.month_val);
INSERT INTO STORES_COMM_MOB_SUB_INFO T1 (
t1.ntlogin,
t1.first_name,
t1.last_name,
t1.job_title,
t1.store_id,
t1.batch_create_dt)
SELECT t2.ntlogin,
t2.first_name,
t2.last_name,
t2.job_title,
t2.store_id,
t2.batch_create_dt
FROM stores_comm_mob_sub_temp t2
WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val
AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
m2.month_val;
ELSIF lv_subpartition_name IS NOT NULL
THEN
DBMS_OUTPUT.PUT_LINE('INSIDE ELSIF => '||m2.month_val);
MERGE INTO (SELECT *
FROM stores_comm_mob_sub_info
SUBPARTITION (lv_subpartition_name)) T1
USING (SELECT *
FROM stores_comm_mob_sub_temp
WHERE TO_CHAR (batch_create_dt, 'YYYY') =
m1.orig_year_val
AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
m2.month_val) T2
ON (T1.store_id = T2.store_id
AND T1.ntlogin = T2.ntlogin)
WHEN MATCHED
THEN
UPDATE SET
t1.postpaid_totalqty =
(NVL (t1.postpaid_totalqty, 0)
+ NVL (t2.postpaid_totalqty, 0)),
t1.sales_transaction_dt =
GREATEST (
NVL (t1.sales_transaction_dt,
t2.sales_transaction_dt),
NVL (t2.sales_transaction_dt,
t1.sales_transaction_dt)),
t1.batch_create_dt =
GREATEST (
NVL (t1.batch_create_dt, t2.batch_create_dt),
NVL (t2.batch_create_dt, t1.batch_create_dt))
WHEN NOT MATCHED
THEN
INSERT (t1.ntlogin,
t1.first_name,
t1.last_name,
t1.job_title,
t1.store_id,
t1.batch_create_dt)
VALUES (t2.ntlogin,
t2.first_name,
t2.last_name,
t2.job_title,
t2.store_id,
t2.batch_create_dt);
END IF;
END LOOP;
END LOOP;
COMMIT;
end;
Much appreciate your inputs here.
Thanks,
MK.I've not used partitioning, but I do not see MERGE supporting a variable as a partition name in
MERGE INTO (SELECT *
FROM stores_comm_mob_sub_info
SUBPARTITION (lv_subpartition_name)) T1
USING ... I suspect it is looking for a partition called lv_subpartition_name.
I also don't see why you need that partition name - the ON clause should be able to identify the partition's criteria. -
Issue while using SUBPARTITION clause in the MERGE statement in PLSQL Code
Hello All,
I am using the below code to update specific sub-partition data using oracle merge statements.
I am getting the sub-partition name and passing this as a string to the sub-partition clause.
The Merge statement is failing stating that the specified sub-partition does not exist. But the sub-partition do exists for the table.
We are using Oracle 11gr2 database.
Below is the code which I am using to populate the data.
declare
ln_min_batchkey PLS_INTEGER;
ln_max_batchkey PLS_INTEGER;
lv_partition_name VARCHAR2 (32767);
lv_subpartition_name VARCHAR2 (32767);
begin
FOR m1 IN ( SELECT (year_val + 1) AS year_val, year_val AS orig_year_val
FROM ( SELECT DISTINCT
TO_CHAR (batch_create_dt, 'YYYY') year_val
FROM stores_comm_mob_sub_temp
ORDER BY 1)
ORDER BY year_val)
LOOP
lv_partition_name :=
scmsa_handset_mobility_data_build.fn_get_partition_name (
p_table_name => 'STORES_COMM_MOB_SUB_INFO',
p_search_string => m1.year_val);
FOR m2
IN (SELECT DISTINCT
'M' || TO_CHAR (batch_create_dt, 'MM') AS month_val
FROM stores_comm_mob_sub_temp
WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val)
LOOP
lv_subpartition_name :=
scmsa_handset_mobility_data_build.fn_get_subpartition_name (
p_table_name => 'STORES_COMM_MOB_SUB_INFO',
p_partition_name => lv_partition_name,
p_search_string => m2.month_val);
DBMS_OUTPUT.PUT_LINE('The lv_subpartition_name => '||lv_subpartition_name||' and lv_partition_name=> '||lv_partition_name);
IF lv_subpartition_name IS NULL
THEN
DBMS_OUTPUT.PUT_LINE('INSIDE IF => '||m2.month_val);
INSERT INTO STORES_COMM_MOB_SUB_INFO T1 (
t1.ntlogin,
t1.first_name,
t1.last_name,
t1.job_title,
t1.store_id,
t1.batch_create_dt)
SELECT t2.ntlogin,
t2.first_name,
t2.last_name,
t2.job_title,
t2.store_id,
t2.batch_create_dt
FROM stores_comm_mob_sub_temp t2
WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val
AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
m2.month_val;
ELSIF lv_subpartition_name IS NOT NULL
THEN
DBMS_OUTPUT.PUT_LINE('INSIDE ELSIF => '||m2.month_val);
MERGE INTO (SELECT *
FROM stores_comm_mob_sub_info
SUBPARTITION (lv_subpartition_name)) T1 --> Issue Here
USING (SELECT *
FROM stores_comm_mob_sub_temp
WHERE TO_CHAR (batch_create_dt, 'YYYY') =
m1.orig_year_val
AND 'M' || TO_CHAR (batch_create_dt, 'MM') =
m2.month_val) T2
ON (T1.store_id = T2.store_id
AND T1.ntlogin = T2.ntlogin)
WHEN MATCHED
THEN
UPDATE SET
t1.postpaid_totalqty =
(NVL (t1.postpaid_totalqty, 0)
+ NVL (t2.postpaid_totalqty, 0)),
t1.sales_transaction_dt =
GREATEST (
NVL (t1.sales_transaction_dt,
t2.sales_transaction_dt),
NVL (t2.sales_transaction_dt,
t1.sales_transaction_dt)),
t1.batch_create_dt =
GREATEST (
NVL (t1.batch_create_dt, t2.batch_create_dt),
NVL (t2.batch_create_dt, t1.batch_create_dt))
WHEN NOT MATCHED
THEN
INSERT (t1.ntlogin,
t1.first_name,
t1.last_name,
t1.job_title,
t1.store_id,
t1.batch_create_dt)
VALUES (t2.ntlogin,
t2.first_name,
t2.last_name,
t2.job_title,
t2.store_id,
t2.batch_create_dt);
END IF;
END LOOP;
END LOOP;
COMMIT;
end;
Much appreciate your inputs here.
Thanks,
MK.
(SORRY TO POST THE SAME QUESTION TWICE).
Edited by: Maddy on May 23, 2013 10:20 PMDuplicate question
-
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,
VirgilioRead 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 -
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 -
Instead of trigger is NOT firing for merge statements in Oracle 10gR2
The trigger fires fine for a update statement, but not when I use a merge statement
with an update clause. Instead I get the normal error for the view ( which is a union all view, and therefore not updatable.)
The error is :-
ORA-01733: virtual column not allowed here
oracle release is 10.2.0.2 for AIX 64L
Is this a known bug ?
I've used a multi-table insert statement to work around the problem for inserts, but
for updates, I'd really like to be able to use a merge statement instead of an update.
Mark.This is my cut-down version :-
In this case case I'm getting an :-
ORA-01446: cannot select ROWID from, or sample, a view with DISTINCT, GROUP BY, etc.
rather then the ora-01733 error I get in the real code ( which is an update from an involved
XML expression - cast to a table form)
create table a ( a int primary key , b char(30) ) ;
create table b ( a int primary key , b char(30) ) ;
create view vw_a as
select *
from a
union all
select *
from b ;
ALTER VIEW vw_a ADD (
PRIMARY KEY
(a) DISABLE);
DROP TRIGGER TRG_IO_U_ALL_AB;
CREATE OR REPLACE trigger TRG_IO_U_ALL_AB
instead of update ON vw_a
for each row
begin
update a targ
set b = :new.b
where targ.a = :new.a
if SQL%ROWCOUNT = 0
then
update b targ
set b = :new.b
where targ.a = :new.a
end if ;
end ;
insert into a values (1,'one');
insert into a values (2,'two');
insert into a values (3,'three');
insert into b values (4,'quatre');
insert into b values (5,'cinq');
insert into b values (6,'six');
commit;
create table c as select a + 3 as a, b from a ;
commit;
merge into vw_a targ
using (select * from c ) src
on ( targ.a = src.a )
when matched
then update
set targ.b = src. b
select * from vw_a ;
rollback ;
update vw_a b
set b = ( select c.b from c where b.a = c.a )
where exists ( select c.b from c where b.a = c.a ) ;
select * from vw_a ;
rollback ; -
Need suggestion in MERGE Statement
Hi,
I have a scenario like, I have one table T1 with 500,000 to 700,000 records and now I want to check the other table T2 if record exists or not. If record exists with opposite amount ( - or + ) as compare with first table T1 then I need to insert this record from second table T2 to first table T1 and if record is not exists then need to update the flag with 'N' in first table T1. Can MERGE statement will be better solution in this scenario?
Thanks,Here's something generic:
insert into T1 (columns...)
select (columns...)
from T1
where exists (select 1
from T2
where T2.some_key = T1.some_key
and T2.some_value + T1.some_value = 0);
update T1
set some_flag = 'N'
where not exists (select 1
from T2
where T2.some_key = T1.some_key);Sure seems odd though. Are you sure you wrote your original question correctly? -
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.
ThanksAssuming 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. -
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
-
How to use Inner join of table as Source in Merge statement in SQL
Hi All,
I am trying to make source as multiple tables output using Join while coding there is no any syntax error but when i am executing this statement is giving following error
Following is the query
Merge Into EmpDept Target
Using (select E.Address,e.Design,e.EmailId,e.EmpId,e.Ename,e.ManagerId, e.Salary,D.DeptId,D.DeptName,D.Location from Employee E Inner join Dept D on E.DeptId=D.DeptId )As Source (Address,Design,EmailId,EmpId,EName,ManagerId,Salary,DeptId,DeptName,Location)
On Source.EmpId=Target.EmpId
when not matched then
Insert (Target.Address,Target.Design,Target.EmailId,Target.EmpId,Target.Ename,Target.ManagerId, Target.Salary,Target.DeptId,Target.DeptName,Target.Location)
values
(Address,Design,EmailId,EmpId,EName,ManagerId, Salary,DeptId,DeptName,Location)
When matched then
Update set Target.Address = Source.Address ,Target.Design = Source.Design,Target.EmailId = Source.EmailId ,Target.Ename = Source.Ename ,Target.ManagerId = Source.ManagerId , Target.Salary = Source.Salary ,Target.DeptId = Source.DeptId ,Target.DeptName = Source.DeptName ,Target.Location = Source.Location;
This is error while executing the above merge statement
The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.
Please suggest me where i am wrong..
Niraj SevalkarMERGE INTO EmpDept Target
Using (SELECT E.Address,
e.Design,
e.EmailId,
e.EmpId,
e.Ename,
e.ManagerId,
e.Salary,
D.DeptId,
D.DeptName,
D.Location
FROM Employee E
INNER JOIN Dept D
ON E.DeptId = D.DeptId) AS Source (Address, Design, EmailId, EmpId, EName, ManagerId, Salary, DeptId, DeptName, Location)
ON Source.EmpId = Target.EmpId
WHEN NOT matched THEN
INSERT (Address,
Design,
EmailId,
EmpId,
Ename,
ManagerId,
Salary,
DeptId,
DeptName,
Location)
VALUES (Address,
Design,
EmailId,
EmpId,
EName,
ManagerId,
Salary,
DeptId,
DeptName,
Location)
WHEN matched THEN
UPDATE SET Address = Source.Address,
Design = Source.Design,
EmailId = Source.EmailId,
Ename = Source.Ename,
ManagerId = Source.ManagerId,
Salary = Source.Salary,
DeptId = Source.DeptId,
DeptName = Source.DeptName,
Location = Source.Location; -
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. -
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 PMFor 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 -
Using Delete in Merge Statement
As merge statement inserts and updates the target data related to the source data but what if the target table contains some additional rows. I mean now both the target table and source tables are not the same. How to do it ?
mshamirtaloo wrote:
As merge statement inserts and updates the target data related to the source data but what if the target table contains some additional rows. I mean now both the target table and source tables are not the same. How to do it ?Well, there's nothing to say that the source and target need to be 'the same' so really not sure what you're asking.
As of Oracle 10 the MERGE command allows for insert, update and delete operations.
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/statements_9016.htm#SQLRF01606
Maybe you are looking for
-
Hi, I have a workflow, the first node is 'Start' Node, then two parallel notifications, both having result type of Approval and then there is 'OR' node. What I want to know is, after OR/AND functions is the result from the previous node gets lost ? B
-
Hi everyone. I am having an issue with applying strokes to images. I have PhotoShop CS5 installed on two PCs, both from the same source download file (part of E-Learning 2 Suite). On one PC the Edit > Stroke effect works absolutely fine, as evidenced
-
when submitting the report it show the following error while I am using the Fnd_Standard_Date parameter in Concurrent Programme and date parameter in my report is dd/mon/yyyy hh:mi:ss whil I have try the Parameter with DD-MON-RRRR but the error is sa
-
Apple ID prompt on iPhone 4S uses old email address
My Hotmail address became Outlook, so I've changed my Apple ID. My iPhone 4S doesn't realise this, though - when it prompts for my password, it uses my old ID. How do I get it to recognise the update?
-
Renaming mutiple files (photos) outside of Iphoto
Hi, I Take a lot of digital photos, but do not use Iphoto as it puts all the photos in hundreds of different folders. I am wondering if I can use Automator to rename a batch of photos (ie. from dsc100001 to JohnsBirthday1 and so on). Any help would b