Please help with update conversion from oracle to Teradata
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Please help with update conversion from... Expand / Collapse
Author
Message
Posted 10/19/2009 4:24:18 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/18/2009 10:51:12 AM
Posts: 6, Visits: 36
Hi ,



This is Oracle query .



update dbname.sharp_app_usage_rpt_details A

set display_format = Coalesce ((select C.propvalue from dbname.sharp_app_usage_rpt_details B, dbname.sharp_properties C where B.request_ID = A.request_ID and B.report_Name = A.report_name and B.report_type = A.report_type and C.systemname = 'dfdf' and C.propname = B.report_name || '.' || B.report_type || '.OutputFmt' and C.PROPVALUE in ('dfd', 'dfda') ), display_format)

where request_id = 56546





Converted TD query





update table_a A FROM (select C.propvalue from

table_b B, table_c C ,table_a A

where B.request_ID = A.request_ID and B.report_Name = A.report_name and B.report_type = A.report_type

and C.systemname = 'dfdf' and C.propname = B.report_name || '.' || B.report_type || '.OutputFmt' and C.PROPVALUE in ('dfd', 'dfda') ) AS D(D1)

SET

display_format = D1

Coalesce (D1 , display_format )

where request_id = 56546



I am getting error as illegal usage of alias name



Thanks


Regards.
Post #17103
Posted 10/19/2009 5:04:56 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 3:55:54 AM
Posts: 111, Visits: 263
Try:

update table_a A FROM (select C.propvalue from

table_b B, table_c C ,table_a A

where B.request_ID = A.request_ID and B.report_Name = A.report_name and B.report_type = A.report_type

and C.systemname = 'dfdf' and C.propname = B.report_name || '.' || B.report_type || '.OutputFmt' and C.PROPVALUE in ('dfd', 'dfda') ) AS D(D1)

SET

display_format = Coalesce (D1 , display_format )
----------------------------------------------

where request_id = 56546
;

Post #17104
Posted 10/19/2009 5:12:58 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/18/2009 10:51:12 AM
Posts: 6, Visits: 36
I got the query compiled without any errors but when I update I get the folowing error :

: [Teradata Database] [TeraJDBC 13.00.00.07] [Error 7547] [SQLState HY000] Target row updated by multiple source rows.

any help on this Please.


Regards.
Post #17105
Posted 10/20/2009 1:01:09 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 3:55:54 AM
Posts: 111, Visits: 263
Apologies - you need to take the key details from your subquery and join them back to the main table.
Try:

update table_a FROM
(select A.Request_Id,
A.Report_Name,
A.Report_Type,
C.propvalue (D1)
from table_b B, table_c C ,table_a A
where B.request_ID = A.request_ID
and B.report_Name = A.report_name
and B.report_type = A.report_type
and C.systemname = 'dfdf'
and C.propname = B.report_name || '.' || B.report_type || '.OutputFmt'
and C.PROPVALUE in ('dfd', 'dfda')
and A.request_id = 56546 ) AS D

SET
display_format = Coalesce (D.D1 , Table_A.display_format )
where Table_A.request_id = D.Request_Id
and Table_A.Report_Name = D.Report_Name
And Table_A.Report_Type = D.Report_Type
;
Post #17106
Posted 10/20/2009 7:14:12 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/18/2009 10:51:12 AM
Posts: 6, Visits: 36
thanks

Regards.
Post #17117
Posted 10/20/2009 7:18:13 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/18/2009 10:51:12 AM
Posts: 6, Visits: 36
I am getting the following error now .Can anybody help on this pelase

Message : [Teradata Database] [TeraJDBC 13.00.00.07] [Error 7547] [SQLState HY000] Target row updated by multiple source rows.

Thanks.


Regards.
Post #17118
Posted 10/27/2009 3:24:39 AM


Forum Guru

Forum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum GuruForum Guru

Group: Forum Members
Last Login: Yesterday @ 12:42:08 AM
Posts: 74, Visits: 32
Hi,
The issue you are seing is that 2 or more rows are appearing from your result set to update one target row. Effectively means that data row duplicates exist in your tables. Try this:

update table_a FROM
(select A.Request_Id,
A.Report_Name,
A.Report_Type,
C.propvalue (D1)
from table_b B, table_c C ,table_a A
where B.request_ID = A.request_ID
and B.report_Name = A.report_name
and B.report_type = A.report_type
and C.systemname = 'dfdf'
and C.propname = B.report_name || '.' || B.report_type || '.OutputFmt'
and C.PROPVALUE in ('dfd', 'dfda')
and A.request_id = 56546
) AS D

SET
display_format = Coalesce (D.D1 , Table_A.display_format )
where Table_A.request_id = D.Request_Id
and Table_A.Report_Name = D.Report_Name
And Table_A.Report_Type = D.Report_Type
;
The section I have marked in BOLD above should be run seperately and checked whether multiple rows are being returned. If so, then simply GROUP BY to reduce this if possible, otherwise solve the problem with appropriate steps. Then your UPDATE will work fine.


Strive to success.

Arun.

Post #17167
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 9:59am

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.094. 6 queries. Compression Disabled.