|
saidev
Posting Yak Master
101 Posts |
Posted - 06/28/2006 : 20:09:47
|
Guys,
I am trying to run these queries in the stored procedure but I am getting the message Can you guys help me what I am doing wrong Thanks
Message "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. Cannot insert duplicate key row in object 'tblAdvertiser' with unique index 'ndxDescr'. The statement has been terminated. The statement has been terminated." String
This is my Stored Procedure
UPDATE tblTempDRSRecord_Contracts SET fkContractType = 'OUNWIRED', fkClient = s.fkRepresentedEntity, fkTrafficSystem = s.TrafficSystem, date = s.OrderDate, product = s.ProductName, Advertiser = s.Advertiser, fkAdvertiser = (select pkid from tblAdvertiser WHERE Description = s.Advertiser), fkprogrambuynumber = s.fkprogrambuynumber FROM tblTempDRSRecord_Contracts t, tblTempDRSRecord s WHERE t.FTSOrderNumber = s.FTSOrderNumber
insert into tbladvertiser (descr,description) SELECT DISTINCT left(advertiser,10) ,advertiser FROM tblTempDRSRecord_contracts where tblTempDRSRecord_contracts.fkadvertiser is null
UPDATE tblTempDRSRecord_Contracts SET fkContractType = 'OUNWIRED', fkClient = s.fkRepresentedEntity, fkTrafficSystem = s.TrafficSystem, date = s.OrderDate, product = s.ProductName, Advertiser = s.Advertiser, fkAdvertiser = (select pkid from tblAdvertiser WHERE Description = s.Advertiser) FROM tblTempDRSRecord_Contracts t, tblTempDRSRecord s WHERE t.FTSOrderNumber = s.FTSOrderNumber AND fkAdvertiser is null

|
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
USA
6997 Posts |
Posted - 06/28/2006 : 20:18:11
|
This subquery is returning more than one value, and that is not allowed when the subquery result is assigned as a column value.
fkAdvertiser = (select pkid from tblAdvertiser WHERE Description = s.Advertiser),
The other message means that you are trying to insert a row that would cause a duplicate.
CODO ERGO SUM |
 |
|