Defined column ambiguous error with the Merge statement
Hi guys,.I get the ' Error (136,4): PL/SQL: ORA-00918: column ambiguously defined "error with the following query of fusion,
MERGE INTO Inv_Stk_Trns_Tail a
USING (SELECT b.*, c.*
FROM OLR b ,Inv_Stk_Trns_Tail c
WHERE b.Trn_Type <> '0'
AND b.VoucherType IS NOT NULL
AND b.VoucherType = 'SF'
AND b.Item_Code = c.Item_Code
AND c.PROPERTY = 0) src
ON (a.Sl_No = src.Sl_No and a.Ref_No = src.Ref_No )
WHEN MATCHED THEN UPDATE SET Item_Avg_Ppr = src.Opn_Avg_Cost,
Rate_Bc = src.Opn_Avg_Cost;
I tried to solve the problem in a lot of ways, but no use. Please help me solve this problem. If you want more details, I'll give you.Thank you
RAM
SELECT B.*, c.
Try all the (necessary) columns on the code and the name of each column a unique alias.
Tags: Database
Similar Questions
-
Error in the Merge statement using dblink
Hello
I am facing the following error when you use the merge statement using the dblink.
ORA-02069: global_names must be set to true for this operation parameter.
I can use the same dblink in my select insert and update statements but when I try to use merge then he invites the error said, is also not any syntax error as same statement can be used on the same tables of database instead of dblink.
Please suggest any help will be much appreciated.
Thanks in advance
Hi Aqeel
If insert and update statements work well through links db, then it should not be a problem with the merge statement. But if you are faced with the question, so please check the entire sql statement with tnsnames on both sides. Please share the tnsnames for the two dbs with dblink ddl.
Concerning
Jihane Narain Sylca
-
Get error in the merge statement
Version of Oracle, Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
Hi gurusI am trying to perform the merge statement using the clause, but I get the error message, see below my sample data:
Examples of data
DROP TABLE OF BILLING;
DROP TABLE GROUP_MST;
DROP TABLE age_max;
CREATE ARRAY OF BILLING
(
BILLING_ID NUMBER (5),
RATE NUMBER (5),
MAXIMUM_AGE NUMBER (5),
package_id NUMBER (5)
);
INSERT
IN BILLING
(SELECT 11,1,10,100 FROM DUAL
UNION ALL
SELECT 12,2,15,100 FROM DUAL
UNION ALL
SELECT 13,3,20,100 FROM DUAL
);
CREATE TABLE GROUP_MST
(group_number NUMBER (5), package_id NUMBER (5))
);
INSERT INTO GROUP_MST
(SELECT DOUBLE 5 000 100
);
-------
CREATE TABLE AGE_MAX
(group_number NUMBER (5), max_age NUMBER (5))
);
INSERT
IN AGE_MAX
(SELECT 5000,60 FROM DUAL
);
Merge statement
MERGE INTO DRC USING billing
(WITH datum1 AS
(SELECT A.group_number,
b.billing_id,
b.rate,
b.maximum_age,
b.package_id
OF group_mst A,.
b billing
WHERE A.package_id = b.package_id
),
datum2 AS
(SELECT max_age, group_number FROM age_max
)
SELECT * FROM A, b WHERE A.group_number = b.group_number datum2 datum1
)
CBC ON (drc.billing_id = src.billing_id)
WHEN MATCHED THEN
UPDATE SET drc.maximum_age = src.max_age - 1;
Error
Error from the 33 in the command line:
MERGE INTO DRC USING billing
(WITH datum1 AS
(SELECT A.group_number,
b.billing_id,
b.rate,
b.maximum_age,
b.package_id
OF group_mst A,.
b billing
WHERE A.package_id = b.package_id
),
datum2 AS
(SELECT max_age, group_number FROM age_max
)
SELECT * FROM A, b WHERE A.group_number = b.group_number datum2 datum1
)
CBC ON (drc.billing_id = src.billing_id)
WHEN MATCHED THEN
UPDATE SET drc.maximum_age = src.max_age - 1
Error in the command line: 50 column: 1
Error report:
SQL error: ORA-00918: column ambiguously defined
00918 00000 - "ambiguously defined column.
* Cause:
* Action:
Thanks in advance
Concerning
Shu
WITH datum1 AS (SELECT A.group_number,
b.billing_id,
b.rate,
b.maximum_age,
b.package_id
OF group_mst A, b billing
WHERE A.package_id = b.package_id),
datum2 AS (SELECT max_age, group_number FROM age_max)
SELECT A.*, b.max_age, b.group_number as group_number_b - ERROR HERE
OF datum1 A, b datum2
WHERE A.group_number = b.group_number
-
need help with the Merge statement
I'm on: Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
I'm currently an UPDATE statement and then it works and is accurate, it takes 30 minutes. I heard that MERGE
can do the same thing and is just as accurate and much faster!
Here's the query I want to convert into a MERGE INTO statement. I tried to do it myself, but I get errors and don't know simply, since it's new for me.
Basically I want to update table your on a corresponding condition in the table tt for 2 columns (GTP and UPDATE_DT), for UPDATE_DT I want to insert the Date current system.
Thank you!UPDATE /*+ PARALLEL (16) */ OLDER_Table ta SET (ta.GTP, ta.UPDATE_DT) = (SELECT /*+ PARALLEL (16) */ tt.GTP, SYSDATE FROM NEWER_Table tt WHERE ta.cust_id = tt.cust_id AND ta.STAMP_DATE = tt.STAMP_DATE AND ROWNUM = 1) WHERE EXISTS (SELECT 1 FROM NEWER_Table tt WHERE ta.cust_id = tt.cust_id AND ta.STAMP_DATE = tt.STAMP_DATE AND (NVL(ta.GTP, 'X') != NVL(tt.GTP, 'X')));
Hello
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
If you ask on a DML statement, such as UPDATE, CREATE TABLE and INSERT statements need to re - create the tables as they are before the DML, and results will be the content of the or the tables changed when it's all over.
See the FAQ forum {message identifier: = 9360002}MERGE peut be much faster than update; Sometimes, there is no significant difference in speed.
Tables in multiple situations like this, I've never seen a case where the MERGER has been slower than the UPDATE, even if the UPDATE is sometimes easier to code and just as fast.Maybe that's what you want:
MERGE INTO older_table dst USING ( SELECT n.cust_id , n.stamp_date , n.gtp , ROW_NUMBER () OVER ( PARTITION BY n.cust_id , n.stamp_date ORDER BY n.gtp ) AS r_num FROM newer_table n JOIN older_table o ON n.cust_id = o.cust_id AND n.stamp_date = o.stamp_date AND NVL ( n.gtp , 'X' ) != NVL ( o.gtp , 'X' ) ) src ON ( src.cust_id = dst.cust_id AND src.stamp_date = dst.stamp_date AND src.r_num = 1 ) WHEN MATCHED THEN UPDATE SET dst.gtp = src.gtp , dst.update_date = SYSDATE ;
As I can't test it, I can't be sure.
-
error with the case statement use what void const query
Hi all.
I have found the error in the result set, and then use subqueries and cases of declaration.
Preparation for example.
2 examples of tables creation.
This statement returns NULL in subqueryCREATE TABLE T1 AS ( SELECT 1 ID , 1 F1 FROM DUAL UNION SELECT 2 ID , 1 F1 FROM DUAL UNION SELECT 3 ID , 1 F1 FROM DUAL ) ; CREATE TABLE T2 AS ( SELECT 2 ID FROM DUAL UNION SELECT 3 ID FROM DUAL ) ;
But this statement (with operator CASE) does NOT return null in subquerySELECT T1.ID, TT2.ID , TT2.ISBUG AS NO_BUG FROM T1 LEFT JOIN ( SELECT ID , -1 ISBUG FROM T2 )TT2 ON T1.ID = TT2.ID WHERE TT2.ID IS NULL
Why?SELECT CASE WHEN 1 = 1 THEN 1 END AS C1, T1.ID, TT2.ID , TT2.ISBUG FROM T1 LEFT JOIN ( SELECT ID , -1 ISBUG FROM T2 )TT2 ON T1.ID = TT2.ID WHERE TT2.ID IS NULL
Oracle 11.2.0.2.0
Published by: 927438 on 13.04.2012 03:27
Published by: 927438 on 13.04.2012 03:31Maybe it is related to this one
outer join of 11g with case - strange results statement.
seems to be a bug
-
Problem with the MERGE statement
Hi all
We'll cover the following:
create table xx_test1 (invoice_id number, line_group_number number, LINE_TYPE_LOOKUP_CODE VARCHAR2(25) ,LINE_NUMBER NUMBER(15) );
Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,1,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,1,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,2,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,2,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,3,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,3,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,4,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,4,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,5,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,5,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,12,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,12,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,7,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,7,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,8,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,8,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,9,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,9,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,10,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,10,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,11,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,11,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,12,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,12,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,13,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,13,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,14,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,14,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,15,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,15,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,16,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,16,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,17,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,17,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,18,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,18,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,19,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,19,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,20,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,20,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,21,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,21,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,22,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,22,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,23,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,23,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,24,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,24,'TAX',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,25,'ITEM',null); Insert into XX_TEST1 (INVOICE_ID,LINE_GROUP_NUMBER,LINE_TYPE_LOOKUP_CODE,LINE_NUMBER) values (131549,25,'TAX',null);
So, if we want to MERGE this table and update the lines with below:
merge into xx_test1 DST USING (SELECT LINE_GROUP_NUMBER, LINE_TYPE_LOOKUP_CODE, ROW_NUMBER() over(order by LINE_TYPE_LOOKUP_CODE, LINE_GROUP_NUMBER) as LINE_NUM from xx_test1 where INVOICE_ID = 131549 ) SRC ON (DST.LINE_GROUP_NUMBER = SRC.LINE_GROUP_NUMBER AND dst.LINE_TYPE_LOOKUP_CODE = src.LINE_TYPE_LOOKUP_CODE AND dst.invoice_id = 131549 ) WHEN MATCHED THEN update set DST.LINE_NUMBER = SRC.LINE_NUM ;
I get an error message:SQL error: ORA-30926: failed to get a stable set of rows in the source tables
30926 00000 - "impossible to get a stable set of rows in the source tables.
* Cause: A stable set of rows could not be achieved due to the large dml
activity or one not deterministic where clause.
* Action: Remove any non deterministic of the clauses and reissue of the dml.
I don't know why I'm getting this. Any ideas?
Version: 11g
Kind regards
Alex
whenever I have this error I convert my fusion in a select to see what is duplication
select dst.LINE_GROUP_NUMBER, dst.LINE_TYPE_LOOKUP_CODE, count(*) from xx_test1 DST join (SELECT LINE_GROUP_NUMBER, LINE_TYPE_LOOKUP_CODE, ROW_NUMBER() over(order by LINE_TYPE_LOOKUP_CODE, LINE_GROUP_NUMBER) as LINE_NUM from xx_test1 where INVOICE_ID = 131549 ) SRC ON (DST.LINE_GROUP_NUMBER = SRC.LINE_GROUP_NUMBER AND dst.LINE_TYPE_LOOKUP_CODE = src.LINE_TYPE_LOOKUP_CODE AND dst.invoice_id = 131549 ) group by dst.LINE_GROUP_NUMBER, dst.LINE_TYPE_LOOKUP_CODE having count(*) > 1
you have 2 dst. LINE_GROUP_NUMBER, summer time. Combination of LINE_TYPE_LOOKUP_CODE this duplication.
-
Person registering in the Merge statement error!
Is it possible to save indivudual error in the MERGE statement (Update / Insert).
I'm unable to save these error. instead of MERGING, if I update the table in the cursor loop then I am able to record the individual error but the process takes time.
Thanks in advance.
DebaHi Deba,
Logging of DML errors:
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>
Concerning
Peter -
Return in the MERGE statement clause
Hello
I use Oracle 10 g Version
I tried the code using UPDATE with return Clause & MERGER with return below Clause.
I have not found ANY error while working with the UPDATE statement. Here is the code with the UPDATE statement
DECLARE TYPE empno_list IS TABLE OF emp.empno%TYPE; vempno_list empno_list; BEGIN UPDATE emp SET comm = 11 WHERE deptno IN (SELECT deptno FROM dept) RETURNING empno BULK COLLECT INTO vempno_list; FOR i IN vempno_list.FIRST .. vempno_list.LAST LOOP DBMS_OUTPUT.put_line ('Values of EMP ' || vempno_list (i)); END LOOP; END;
But PL/SQL error: ORA-00933: SQL not correctly completed command when you work with the MERGE statement
declare type empno_list is table of emp.empno%type; vempno_list empno_list; begin merge into emp tgt using dept src on (src.deptno =tgt.deptno) when matched then update set tgt.comm=12 returning tgt.empno bulk collect into vempno_list ; for i in vempno_list.first .. vempno_list.last loop dbms_output.put_line('Values of EMP '||vempno_list(i) ) ; end loop; end;
Please suggest me
Probably because BACK IN clause does not belong to the MERGE statement. It is available only for INSERT, UPDATE, and DELETE. Here's the quote from Oracle Documentation:
The static method
RETURNING
INTO
article belongs to aDELETE
,INSERT
, orUPDATE
statement. The dynamicRETURNING
INTO
article belongs to aEXECUTE
IMMEDIATE
statement.And here is the link.
It will be useful.
Ishan
-
Hello! I got this message from malware (I clicked to delete) in surfing on firefox and after awhile the explorer.exe closes with an error. I try to open the Task Manager and it says explore cannot be found!
I rebooted and then I got this message "0xC000021A {fatal system error}, the initial session process or the process of the complete system in unexpected ways with the blocking state 0 x 00000000 (0xc0000034 0x001008ac) the system has been halted" and can't get anywhere.
I can't even go in safe mode, the same error messages appears.Hi James,
You could try the Startup Repair to see if it solves the problem:
http://Windows.Microsoft.com/en-us/Windows-Vista/startup-repair-frequently-asked-questions
Chris
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
Different result by using the MERGE statement
I have 2 SQL statements:
MERGE INTO PT_CQS_AGGR APC
With the HELP of PT_CQS_AGGR_TEMP Lady
WE (concat (concat(pca.from_city_id,pca.to_city_id), pca.query_timestamp_hh) = concat (concat(pcah.from_city_id,pcah.to_city_id), pcah.query_timestamp_hh))
WHEN MATCHED THEN
Setting a DAY SET pca.search_count = pca.search_count + pcah.search_count
WHEN NOT MATCHED THEN
VALUES of INSERTION (to_city_id, query_timestamp_hh, from_city_id, search_count) (pcah.from_city_id, pcah.to_city_id, pcah.query_timestamp_hh, pcah.search_count);
AND
MERGE INTO PT_CQS_AGGR APC
With the HELP of PT_CQS_AGGR_TEMP Lady
WE (pca.from_city_id = pcah.from_city_id AND pca.to_city_id = pcah.to_city_id AND pca.query_timestamp_hh = pcah.query_timestamp_hh)
WHEN MATCHED THEN
Setting a DAY SET pca.search_count = pca.search_count + pcah.search_count
WHEN NOT MATCHED THEN
VALUES of INSERTION (to_city_id, query_timestamp_hh, from_city_id, search_count) (pcah.from_city_id, pcah.to_city_id, pcah.query_timestamp_hh, pcah.search_count);
First statement correctly the merged data, but use FULL TABLE SCANS, so it's rather slow. Second statement using a UNIQUE INDEX on the columns from_city_id, to_city_id, and query_timestamp_hh on the MAP of EXPLAIN, but during the execution of I've got ORA-00001: unique constraint (PODOWNER. IDX_CQS_AGGR_3COL) violated. What is the problem with the second statement - especially with this line:
WE (pca.from_city_id = pcah.from_city_id AND pca.to_city_id = pcah.to_city_id AND pca.query_timestamp_hh = pcah.query_timestamp_hh) Can I use a more complex condition in the MERGE statement? Because it seems that not all the conditions have been taken...
???
Select pcah.from_city_id, pcah.to_city_id, PT_CQS_AGGR_TEMP Lady pcah.query_timestamp_hh
less
Select pca.from_city_id, pca.to_city_id, pca.query_timestamp_hh PT_CQS_AGGR pca
somewhere the conditions limiting the time.
(or whatever the columns make up the stress of failing)
In addition, select for each column in the constraint of failure where the column is null. If one of these columns is null, equality fails, even if both are null, because null <> null. So you will get a "no match" if all values are the same and it is set to null.
Edit: Oh, slap forehead, that is why one works and the complete analysis. As SomeoneElse said, it normalizes the type of data and concatenates, comparison null to no effect and refusing all usual index.
-
Question about the MERGE statement
Hi all
I have a small question... I can post code, table creation, etc... but I think this question can be able to be simply answered, if I explain it. If you want me to zip codes, etc... then just ask and I'll do it.
Here it goes:
I have a set up merge statement, and I have two columns. One is named ADD_DT, and the other is called LST_UPD_DT.
Update in the merge statement, the LST_UPD_DT column is updated with the SYSDATE.
When it is inserted in the merge statement, the ADD_DT column is updated with the SYSDATE.
So, here is my question:
Regardless of whether or not the information is updated, the LST_UPD_DT updates the SYSDATE every time. Any advice on how to update the LST_UPD_DT column only if information is changed/updated, so that the information is not changed would be not updated by the SYSDATE? I hope that this question was not too complicated.
Thank you all and if you want to see the code or examples of table... Please ask and I'll post one. I just thought that this may be able to meet without it.Hello
991769 wrote:
OK, here's what the table looks like:Thank you.
CREATE TABLE TBL_SUPPLIERS ( SUPP_CD VARCHAR2(40 CHAR), SUPP_NM VARCHAR2(255 CHAR), ADD_DT VARCHAR2(50 CHAR), LST_UPD_DT VARCHAR2(50 CHAR))
Do not use a VARCHAR2 column for date information. Use a DATE column.
CREATE TABLE D_SUPPLIERS ( SUPP_CD VARCHAR2(40 CHAR), SUPP_NM VARCHAR2(255 CHAR))
INSERT INTO TBL_SUPPLIERS VALUES (1234, MINING, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM'); INSERT INTO TBL_SUPPLIERS VALUES (2345, ELECTRIC, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM'); INSERT INTO TBL_SUPPLIERS VALUES (3456, COAL, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
You want people to view the solutions that actually work? Please make sure that your own instructions will actually work. Test and fix your code before posting.
All INSERT statements you posted fail; You seem to be missing single quotes around string literals. I think you meant:INSERT INTO TBL_SUPPLIERS VALUES (1234, 'MINING', '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM'); ...
Here's one way:
MERGE INTO tbl_suppliers sm USING ( SELECT d.* FROM d_suppliers d LEFT OUTER JOIN tbl_suppliers t ON t.supp_cd = d.supp_cd WHERE t.supp_cd IS NULL OR DECODE (t.supp_nm, d.supp_nm, 0, 1) = 1 ) ds ON (sm.supp_cd = ds.supp_cd) WHEN MATCHED THEN UPDATE SET sm.supp_nm = ds.supp_nm, sm.lst_upd_dt = SYSDATE WHEN NOT MATCHED THEN INSERT (sm.supp_cd, sm.supp_nm, sm.add_dt) VALUES (ds.supp_cd, ds.supp_nm, SYSDATE); SELECT * FROM tbl_suppliers ORDER BY SUPP_CD;
This can be more efficient, because it does not generate redo, or triggers, when two tables have exactly the same line.
-
Performance issue with the Update statement
Oracle 10204
I have a problem related to updaing one performance table.
only 5000 lines should be updated.
Hir are some details on the tables/M.V concerned:
I tried to run the update with two options:TABLE_NAME LAST_ANALYZED NUM_ROWS SAMPLE_SIZE PS_RF_INST_PROD 1/20/2010 1:14:22 AM 7194402 7194402 BL_TMP_INTRNT 1/27/2010 9:08:54 AM 885445 885445 NAP_INTERNET 1/25/2010 11:47:02 AM 7053990 560777
1. with the plan than oracle choose.
2. with notes I added.
In both cases I he collapsed after more than an hour.
Can any one suggest how to speed it up?
Below are for the two option tkprof.
Plan 1Please note that beside the defualt statistics on those tables i also gathered statistics on two column level as followed: BEGIN SYS.DBMS_STATS.GATHER_TABLE_STATS ( OwnName => 'B' ,TabName => 'BL_TMP_INTRNT' ,Estimate_Percent => 100 ,Degree => 8 ,Cascade => TRUE ,No_Invalidate => FALSE); END; / exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns SERVICE_UID size 254'); exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns FIX_IP_USER size 254');
plan 2UPDATE BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.03 0.02 0 0 0 0 Execute 1 1166.64 4803.78 17989002 18792167 117 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 1166.67 4803.81 17989002 18792167 117 0 Misses in library cache during parse: 1 Optimizer mode: FIRST_ROWS Parsing user id: 13 Rows Row Source Operation ------- --------------------------------------------------- 0 UPDATE BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=2 us) 46 TABLE ACCESS FULL BL_TMP_INTRNT (cr=586400 pr=22228 pw=0 time=15333652 us) 15 HASH JOIN (cr=18170453 pr=17931639 pw=0 time=3991064192 us) 46 MAT_VIEW ACCESS FULL NAP_INTERNET (cr=5659886 pr=5655436 pw=0 time=988162557 us) 329499624 MAT_VIEW ACCESS FULL PS_RF_INST_PROD (cr=12545734 pr=12311281 pw=0 time=2636471644 us)
UPDATE BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT /*+ index(b NAP_INTERNET_PK) index(c PS_RF_INST_PROD_PK)*/ C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.02 0.02 0 0 0 0 Execute 1 4645.25 4613.70 95783 39798095 735 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 4645.27 4613.73 95783 39798095 735 0 Misses in library cache during parse: 1 Optimizer mode: FIRST_ROWS Parsing user id: 13 Rows Row Source Operation ------- --------------------------------------------------- 0 UPDATE BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=1 us) 473 TABLE ACCESS FULL BL_TMP_INTRNT (cr=10461 pr=10399 pw=0 time=4629385 us) 408 MAT_VIEW ACCESS BY INDEX ROWID PS_RF_INST_PROD (cr=39776109 pr=85381 pw=0 time=4605125045 us) 1350 NESTED LOOPS (cr=39784584 pr=84974 pw=0 time=4601874262 us) 470 MAT_VIEW ACCESS BY INDEX ROWID NAP_INTERNET (cr=23569112 pr=50472 pw=0 time=2544364336 us) 470 INDEX FULL SCAN NAP_INTERNET_PK (cr=23568642 pr=50005 pw=0 time=2540300981 us)(object id 11027362) 408 INDEX FULL SCAN PS_RF_INST_PROD_PK (cr=16215472 pr=34502 pw=0 time=2057500175 us)(object id 10980137) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 1300 0.50 4.27 db file sequential read 85707 0.51 29.88 latch: cache buffers chains 1 0.00 0.00 log file sync 1 0.00 0.00 SQL*Net break/reset to client 1 0.00 0.00 SQL*Net message to client 1 0.00 0.00 SQL*Net message from client 1 14.73 14.73 ********************************************************************************
The problem in your update statement that is the query in your set clause is executed many times that there are lines in BL_TMP_INTRNT of 'intellectual property' in their column of term_desc. You mentioned there are about 5000, then the query joining NAP_INTERNET with PS_RF_ISNT_PROD is begun 5000 times.
The trick is to join only once, be updated using join views - provided that it is preserved - key or by using the merge statement.Here is an example:
SQL> create table bl_tmp_intrnt (fix_ip_user,service_uid,term_desc) 2 as 3 select level 4 , level 5 , 'aipa' 6 from dual 7 connect by level <= 5000 8 / Tabel is aangemaakt. SQL> create table nap_internet (inst_prod_id,setid,nap_surf_uid) 2 as 3 select level 4 , 'SHARE' 5 , level 6 from dual 7 connect by level <= 10 8 / Tabel is aangemaakt. SQL> create table ps_rf_inst_prod (product_id,inst_prod_id) 2 as 3 select level 4 , level 5 from dual 6 connect by level <= 10 7 / Tabel is aangemaakt. SQL> exec dbms_stats.gather_table_stats(user,'bl_tmp_intrnt') PL/SQL-procedure is geslaagd. SQL> exec dbms_stats.gather_table_stats(user,'nap_internet') PL/SQL-procedure is geslaagd. SQL> exec dbms_stats.gather_table_stats(user,'ps_rf_inst_prod') PL/SQL-procedure is geslaagd. SQL> set serveroutput off SQL> update ( select a.fix_ip_user 2 , c.product_id 3 from bl_tmp_intrnt a 4 , nap_internet b 5 , ps_rf_inst_prod c 6 where a.term_desc like '%ip%' 7 and a.service_uid = b.inst_prod_id 8 and b.setid = 'SHARE' 9 and b.nap_surf_uid = c.inst_prod_id 10 ) 11 set fix_ip_user = product_id 12 / set fix_ip_user = product_id * FOUT in regel 11: .ORA-01779: cannot modify a column which maps to a non key-preserved table
Join is one key kept in the case of b.inst_prod_id and c.inst_prod_id are unique. Please refer to the documentation for more information here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/views.htm#sthref3055
SQL> alter table nap_internet add primary key (inst_prod_id) 2 / Tabel is gewijzigd. SQL> alter table ps_rf_inst_prod add primary key (inst_prod_id) 2 / Tabel is gewijzigd. SQL> update /*+ gather_plan_statistics */ 2 ( select a.fix_ip_user 3 , c.product_id 4 from bl_tmp_intrnt a 5 , nap_internet b 6 , ps_rf_inst_prod c 7 where a.term_desc like '%ip%' 8 and a.service_uid = b.inst_prod_id 9 and b.setid = 'SHARE' 10 and b.nap_surf_uid = c.inst_prod_id 11 ) 12 set fix_ip_user = product_id 13 / 10 rijen zijn bijgewerkt. SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last')) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------------------------------------------------------------- SQL_ID c7nqbxwzpyq5p, child number 0 ------------------------------------- update /*+ gather_plan_statistics */ ( select a.fix_ip_user , c.product_id from bl_tmp_intrnt a , nap_internet b , ps_rf_inst_prod c where a.term_desc like '%ip%' and a.service_uid = b.inst_prod_id and b.setid = 'SHARE' and b.nap_surf_uid = c.inst_prod_id ) set fix_ip_user = product_id Plan hash value: 1745632149 --------------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | --------------------------------------------------------------------------------------------------------------------------------------- | 1 | UPDATE | BL_TMP_INTRNT | 1 | | 0 |00:00:00.01 | 32 | | | | | 2 | NESTED LOOPS | | 1 | 10 | 10 |00:00:00.01 | 21 | | | | | 3 | MERGE JOIN | | 1 | 10 | 10 |00:00:00.01 | 9 | | | | |* 4 | TABLE ACCESS BY INDEX ROWID| NAP_INTERNET | 1 | 10 | 10 |00:00:00.01 | 2 | | | | | 5 | INDEX FULL SCAN | SYS_C00132995 | 1 | 10 | 10 |00:00:00.01 | 1 | | | | |* 6 | SORT JOIN | | 10 | 250 | 10 |00:00:00.01 | 7 | 267K| 256K| 237K (0)| |* 7 | TABLE ACCESS FULL | BL_TMP_INTRNT | 1 | 250 | 5000 |00:00:00.01 | 7 | | | | | 8 | TABLE ACCESS BY INDEX ROWID | PS_RF_INST_PROD | 10 | 1 | 10 |00:00:00.01 | 12 | | | | |* 9 | INDEX UNIQUE SCAN | SYS_C00132996 | 10 | 1 | 10 |00:00:00.01 | 2 | | | | --------------------------------------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 4 - filter("B"."SETID"='SHARE') 6 - access("A"."SERVICE_UID"="B"."INST_PROD_ID") filter("A"."SERVICE_UID"="B"."INST_PROD_ID") 7 - filter("A"."TERM_DESC" LIKE '%ip%') 9 - access("B"."NAP_SURF_UID"="C"."INST_PROD_ID") 32 rijen zijn geselecteerd. SQL> rollback 2 / Rollback is voltooid.
And it's your current statement. Please note the number of 5000 in the column begins:
SQL> UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A 2 SET A.FIX_IP_USER = 3 (SELECT C.PRODUCT_ID 4 FROM NAP_INTERNET B, PS_RF_INST_PROD C 5 WHERE B.INST_PROD_ID = A.SERVICE_UID 6 AND B.SETID = 'SHARE' 7 AND C.INST_PROD_ID = B.NAP_SURF_UID) 8 WHERE A.TERM_DESC LIKE '%ip%' 9 / 5000 rijen zijn bijgewerkt. SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last')) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------------------------------------------------------------- SQL_ID f1qtnpa0nmbh8, child number 0 ------------------------------------- UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' Plan hash value: 3190675455 ----------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | ----------------------------------------------------------------------------------------------------------- | 1 | UPDATE | BL_TMP_INTRNT | 1 | | 0 |00:00:00.10 | 5076 | |* 2 | TABLE ACCESS FULL | BL_TMP_INTRNT | 1 | 250 | 5000 |00:00:00.01 | 7 | | 3 | NESTED LOOPS | | 5000 | 1 | 10 |00:00:00.02 | 24 | |* 4 | TABLE ACCESS BY INDEX ROWID| NAP_INTERNET | 5000 | 1 | 10 |00:00:00.01 | 12 | |* 5 | INDEX UNIQUE SCAN | SYS_C00132995 | 5000 | 1 | 10 |00:00:00.01 | 2 | | 6 | TABLE ACCESS BY INDEX ROWID| PS_RF_INST_PROD | 10 | 10 | 10 |00:00:00.01 | 12 | |* 7 | INDEX UNIQUE SCAN | SYS_C00132996 | 10 | 1 | 10 |00:00:00.01 | 2 | ----------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("A"."TERM_DESC" LIKE '%ip%') 4 - filter("B"."SETID"='SHARE') 5 - access("B"."INST_PROD_ID"=:B1) 7 - access("C"."INST_PROD_ID"="B"."NAP_SURF_UID") 29 rijen zijn geselecteerd.
Kind regards
Rob. -
Satellite L350-214 - error with the software Reeltime
Hello
I have a Satellite L350-214 with Windows 7 Pro and have encountered an error with the software Reeltime, I uninstalled and reinstalled and still get the error below. Any help or assistance would be great
Tony Miller
Log name: Application
Source: Windows Error Reporting
Date: 2010-11-30 12:27:58
Event ID: 1001
Task category: no
Level: Information
Keywords: Classic
User: n/a
Computer: Tony-TOSH
Description:
Fault bucket 1223018385, type 5
Event name: CLR20r3
Answer: No available
Cabin ID: 0
Signature of the problem:
P1: tosreeltime.exe
P2: 1.0.0.0
P3: 4a769d0e
P4: WindowsBase
P5: 3.0.0.0
P6: 4b5950b7
P7: a86
P8: 18
P9: System.InvalidOperationException
P10:
Attached files:
C:\Users\Tony\AppData\Local\Temp\WER7C9E.tmp.WERIn ternalMetadata.xml
These files are available here:
C:\Users\Tony\AppData\Local\Microsoft\Windows\WER\ ReportArchive\AppCrash_tosreeltime.exe_25c5a6496c7 ad44943ce88637e3389e8a80bd45_07f0c745
Symbol of the analysis:
Recheck for solution: 0
Report ID: d5b71327-fc74-11df-a596-00266c333aed
State: 0
The event XML:
1001
4
0
0 x 80000000000000
37886
Application
Tony-TOSH
1223018385
5
CLR20r3
Not available
0
tosreeltime.exe
1.0.0.0
4a769d0e
WindowsBase
3.0.0.0
4b5950b7
A86
18
System.InvalidOperationException
C:\Users\Tony\AppData\Local\Temp\WER7C9E.tmp.WERIn ternalMetadata.xml
C:\Users\Tony\AppData\Local\Microsoft\Window s\WER\ReportArchive\AppCrash_tosreeltime.exe_25c5a 6496c7ad44943ce88637e3389e8a80bd45_07f0c745
0
d5b71327-fc74-11df-A596-00266c333aed
0
My system specsHey,.
If you get this error Reeltime, you should try Ccleaner. There may be a registry problem and CCleaner might solve this problem. This great freeware and easy tool which you can download here:
http://www.Piriform.com/Check this box!
-
vCenter 4.1/ESXi 4.1 material status "Communication error with the server.
I am slot that a brand new installation of vCenter with two new installs of ESXi 4.1 connected on it. I use on Dell PowerEdge 2950 s ESXi servers. I tired the customized version of Dell and vmware ESXi vanilla version. My host vCenter is Windows 2008 R2.
In vCenter, the two server ESXi, any version of ESXi, I run, I get "Communication error with the server" error when I click the tab hardware state. No data appears in the hardware status tab.
Only suggestion of Dell has been updated with firmware/BIOS on the server level. I did and it did not help.
Anyone has any suggestions or ideas what would cause this?
I had exactly the same problem what is to have everyone on this thread. I finally called VMware support. It is certainly a problem with Tomcat. Apparently, during my initial installation of tomcat server vCenter (on a Win2k8R2 vanilla Server / unreleased) na not create a database file. The vCenter Server uninstalled eventuall tech and went through the Setup again. For some reason any Tomcat created db it's good the second time. After installation, it takes about 5 minutes for the db should be created.
On Windows 2k8R2 it is located here: C:\Program Files\VMware\Infrastructure\tomcat\lib\xhiveConfig\data
The name of the comic is VcCache-by default-0. XhiveDatabase.DB
My server didn't have one at all. The relocation has created, at the beginning it is 0KB in size. After 5 minutes, it grows up to 25, 600KB.
Everything in my vCenter works now correctly. I'm on 4.1.320137
I hope this helps.
Dave
-
ORA-02267: column type incompatible with the type of the referenced column
create table employee)
emp_id varchar (10) constraint Primary Key of PK_employee,.
First name varchar2 (20).
LastName varchar2 (20).
Phone number (11));
Table created.
create the empinformation table
(
primary key pk_empinformation number (6) MobileNo constraint
Address varchar (100),
number (10) of salary.
personalid number (10) constraints fk_employees_section references employee (emp_id));
ERROR on line 6:
ORA-02267: column type incompatible with the type of the referenced columnThis error comes because the data type of the columns of refernce incompatible with reference tables.
Foreign key column data type is the same as the reference column.type database foreign key and primary key data type must myself.
create the empinformation table
(
primary key pk_empinformation number (6) MobileNo constraint
Address varchar (100),
number (10) of salary.
personalid varchar (10) constraints fk_employees_section references employee (emp_id));table created
Maybe you are looking for
-
Eprint works with 1536dnf Laserjet? In the case where it does how to find the email address of my printer? Thank you GAL
-
My iPhone 6 and safari does not work after update 9.3!
I did the iPhone update this morning 9.3 (13E233) and now my research of safari do not work. I can get, but then when I click on a result, nothing happens. Does anyone else have this problem and any suggestions to fix it?
-
What type of object is of class 'NumericText '?
In this thread I asked the Q above. I can't find anything that I can bring that is in this category. And since I can't create the control of ref, still me have to wonder what would be an object "NumericText" on the PC. Just curious,. Ben
-
Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas:? PH false calls from people posing as employees of Microsoft to help me with the infection by the virus. Others have similar appeals? Y
-
I just got a memory card for my phone and im trying to use it, but when I had to format it on my computer it doesn't let me, nobody knows not wat is wrong or how I could solve this problem?