October 13, 2010 at 10:10 am
I have a bunch of UDFs in Oracle10g. I wanna use them from SQL Server.
Since i have my Oracle linked to SQL Server.
I write the query as
SELECT *
FROM OPENQUERY(OracleSvr, 'SELECT name, MY_USER_DEFINEd_FUNCTION('234567') FROM joe.titles')
Where 234567 is my account id which is i/p paramaeter for my UDF.
Cool. .. It works fine and i get the result.
BUT WHEN I TRY TO USE A VARIABLE IN PLACE OF actual accoutn number.
since my column name is 'acctid'
When i substitute '234567' with '@acctid'
🙁 I get an error 🙁
The error simple says that this open query cannot be run blah blah
Please help
[font="Verdana"]
Today is the tomorrow you worried about yesterday:-)[/font]
October 13, 2010 at 3:45 pm
if I understand what you are asking, I don't think openquery can use variables. In the past I have had to build out the statements dynamically.
DECLARE @QryString as nVarchar(MAX)
SET @QryString = 'SELECT * FROM OPENQUERY(OracleSvr, ''SELECT name, MY_USER_DEFINEd_FUNCTION(''' + @acctid + ''') FROM joe.titles'')'
EXEC sp_executesql @QryString
I may have screwed up a quote or two.. sorry if the formatting is off, first post...
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply