1

I have linked SQL Server 2005 to an Oracle Server, and am using OpenQuery() to pass data from Oracle to SQL Server.

So, for instance, the following query works fine:

SELECT *
FROM OPENQUERY(ORACLE_LINK, 'SELECT FIELD1
    FROM ORACLE.TABLE1');

Everything works, unless I ask for a field which is a date/time in the Oracle database. For instance, say that TABLE1 has ten fields, one of which is a timestamp. If I ask for all nine fields except for the timestamp, it works. If I ask:

SELECT *
FROM OPENQUERY(ORACLE_LINK, 'SELECT *
    FROM ORACLE.TABLE1');

I get the following error:

OLE DB provider "MSDAORA" for linked server "ORACLE_LINK" returned message "Oracle error occurred, but error message could not be retrieved from Oracle.".
OLE DB provider "MSDAORA" for linked server "ORACLE_LINK" returned message "Data type is not supported.".

I also get the same error if I ask for only the timestamp field.

What is the best way of handling this error? Thanks.

1 Answer 1

2

I do it with this function (partial code):

select @StringOut = '{ts ''''' + convert(varchar(20), @DateIn, 20) + ''''' }';
RETURN @StringOut

and this goes into the query:

and procedure_date_dt = ' + dbo.TimestampString(@date) + '
and event_type = ''''Time Notation''''

and it works when I run it.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. Are you able to elaborate on how to use this partial code with the code example in my question?
Oh, you are having trouble in the select clause. What happens when you run "select * from openquery (ORACLE_SISI, 'select sysdate from dual');", but with your server name?
I get the now-time, successfully.
What is the datatype of the problematic field?
It is a timestamp. I've solved the problem by casting the timestamp as a date in the query string. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.