I keep getting this error when i try to update to an oracle table through SQL:
An error occurred while preparing a query for execution against OLE DB provider 'MSDAORA'.
OLE DB error trace [OLE/DB Provider 'MSDAORA' ICommandPrepare::Prepare returned 0x80040e14].
This is the code I'm using:
**************
DECLARE @.cmd VARCHAR(500)
DECLARE @.Link VARCHAR(100)
set @.Link = Oracle_DB'
DECLARE @.Table VARCHAR(100)
set @.Table = 'Product_table'
declare @.Factory varchar(3)
set @.Factory = 'N12'
declare @.ProdPull varchar(10)
set @.ProdPull = '10500'
declare @.Prod varchar(25)
set @.Prod = ' 44JBGG'
declare @.WW varchar(6)
set @.WW = '200704'
declare @.SchedType varchar(15)
set @.SchedType = 'SCHED 1'
SET @.cmd =
'
select * from OPENQUERY
(
' + @.Link + ',
''
UPDATE '+ @.Table +'
SET TARGET_VALUE = '+@.ProdPull+'
WHERE TARGET_LEVEL2_VALUE = '+@.Prod+'
AND PERIOD_VALUE = '+@.WW+'
AND TARGET_LEVEL_VALUE = '+@.Factory+'
AND TARGET_TYPE = '+@.SchedType+'
''
)
'
EXEC (@.cmd)
*********
Have no idea why this isn't working .. help appreciated.
You need quotes around your string values in the update.
UPDATE '+ @.Table +' SET TARGET_VALUE = '''+@.ProdPull+''' WHERE TARGET_LEVEL2_VALUE = '''+@.Prod+''' AND PERIOD_VALUE = '''+@.WW+''' AND TARGET_LEVEL_VALUE = '''+@.Factory+''' AND TARGET_TYPE = '''+@.SchedType+''''
|||
spot on that worked 100%
but now I am getting this error Unable to start a nested transaction for OLE DB provider 'MSDAORA'. A nested transaction was required because the XACT_ABORT option was set to OFF.
I tried turning XACT_ABORT on but then the update statement just doens't work.
Any ideas anybody.
No comments:
Post a Comment