Oracle and SQL Server Data Interoperability Issues - Part 1

  • Good article. The problems were well discussed.

  • Good Article and Good Topic.

    I also stumbeled accross the oracle timestamp issue and used TO_CHAR as well to get around it.

    Btw, here is some information regarding the deprecated timestamp datatype and its replacement "rowversion" in SQL Server 2008.

    http://msdn.microsoft.com/en-us/library/ms182776(SQL.100).aspx

    Best Regards,

    Chris Büttner

  • Your article referred to timestamps but I've had the same problem with date fields in Oracle and had to do the same thing you suggested and convert them to character data to make it work.

  • Excellent article. I've found it's a crapshoot getting things to work w/ oracle reliably from SQL server.....

  • What a timely article for me. I recently found out that I might have to do some queries/reports off of another agency's Oracle database. I've only worked with MS database products and Sybase. I don't know anything about Oracle. Any advice or "gotchas" people have on doing queries off of Oracle would be appreciated.

    Thanks,

    - JJ

  • I'm running into the same problems with OPENQUERY. Not being able to provide it with a string argument containing a dynamically created query is just brain-dead as far as I can see. I, too would like to see the rationale for this.

    Building up the entire SQL server SQL statement is fine if you simply want to display the output of a query but I need to be able to set variables in a stored procedure or trigger with values abstracted from an Oracle database for further use, but variables set inside an sp_executesql call are localised. Thus

    ALTER PROCEDURE SR_numinput

    @SR_num VARCHAR(20),

    @cust Varchar(50) OUTPUT,

    @proj varchar(20) OUTPUT

    AS

    BEGIN

    declare @query NVARCHAR(500);

    set @query =

    'select @cust = NAME, @proj = PROJ_NUM FROM

    openquery(AtlasTest,

    ''Select P.NAME,P.PROJ_NUM from SXXX.S_SRV_REQ S, SXXX.S_PROJ P

    where p.row_id=s.proj_id and s.sr_num='''''+@SR_Num + ''''' '')';

    --select @query;

    execute sp_executesql @query;

    select @cust as oCustomer, @proj as oProject;

    END

    puts out a msg states that @cust must be declared when the statement is executed, and @cust declared in the procedure itself does not get set.

    Any workarounds gratefully received - Thanks

    Giles

  • Got it - using some of the hints earlier in the thread:

    [font="Courier New"]ALTER PROCEDURE SR_numinput

    @SR_number VARCHAR(20),

    @customer VARCHAR(50) OUTPUT,

    @project VARCHAR(20) OUTPUT

    AS

    BEGIN

    declare @query NVARCHAR(500);

    declare @parm NVARCHAR(500);

    set @parm = N'@cust VARCHAR(50) OUTPUT,

    @proj VARCHAR(50) OUTPUT';

    set @query =

    'select @cust = NAME, @proj = PROJ_NUM FROM

    openquery(AtlasTest,

    ''Select P.NAME,P.PROJ_NUM from SXXX.S_SRV_REQ S, SXXX.S_PROJ P

    where p.row_id=s.proj_id and s.sr_num='''''+@SR_Number + ''''' '')';

    select @query;

    execute sp_executesql @query,

    @parm,

    @Cust = @customer OUTPUT,

    @Proj = @project OUTPUT;

    select @customer as oCustomer, @project as oProject;

    END[/font]

    Build up the select string with the input values included.

    Then use sp_executesql with defining the OUTPUT variables required, and map them to the procedure/trigger variables in the call.

    Kind of ugly, but there it is.

  • Did you ever resolve this issue?

    Ken Pearson

  • My second post showed how I got around the problem - it offends my aesthetic sensibilities but that's TSQL for you.

  • You proposed a work-around for using select openquery but not when using insert openquery. I'd appreciate if you could suggest a work around when inserting into a timestamp column from SQL server using Oracle Linked Server. Here is my syntax:

    insert OPENQUERY(OracleLinkedServer, 'SELECT [Other Columns], TimeStampColumn FROM OracleSchema.OracleTable')

    select @data, CONVERT(datetime2(7),'2007-05-02T19:58:47.1234567')

    TimeStampColumn in Oracle has a datatype of TIMESTAMP(6). I tried all the following to insert timestamps in Oracle but I get the same error in all cases:

    Error:

    OLE DB provider "MSDAORA" for linked server "" returned

    message "Oracle error occurred, but error message could not be retrieved

    from Oracle.".

    OLE DB provider "MSDAORA" for linked server "" returned

    message "Data type is not supported.".

    Msg 7321, Level 16, State 2, Line 5

    An error occurred while preparing the query "" for execution against OLE DB provider "MSDAORA" for linked server "".

Viewing 10 posts - 16 through 25 (of 25 total)

You must be logged in to reply to this topic. Login to reply