Solved

linked server not receiving predicates in 'where' clause with numeric columns

Posted on 2003-11-24
8
611 Views
Last Modified: 2008-02-01
Hi.

If I issue a query to a linked server, only the predicates in the 'where' clause that reference character data types are sent to the linked server.

I'm running SQL Server 2000 Service Pack 3.  The linked server is an Oracle 9.2.0 database.  The link uses the Microsoft OLE DB provider for Oracle.

Query 1 on SQL Server:
select *
from PINE_MS..SCOTT.BONUS
where COMM = 5
Resulting query sent to Oracle linked server:
SELECT Tbl1001."COMM" Col1006,
      Tbl1001."SAL" Col1005,
      Tbl1001."JOB" Col1004,
      Tbl1001."ENAME" Col1003
FROM "SCOTT"."BONUS" Tbl1001

Query 2 on SQL Server:
select *
from PINE_MS..SCOTT.BONUS
where ENAME = 'SCOTT'
Resulting query sent to Oracle linked server:
SELECT Tbl1001."ENAME" Col1003,
      Tbl1001."JOB" Col1004,
      Tbl1001."SAL" Col1005,
      Tbl1001."COMM" Col1006
FROM "SCOTT"."BONUS" Tbl1001
WHERE Tbl1001."ENAME"='SCOTT'

Both these queries reference the BONUS table in the sample SCOTT/TIGER schema.
SQL> desc scott.bonus
 Name                                      Null?    Type
 ----------------------------------------- -------- ------------
 ENAME                                              VARCHAR2(10)
 JOB                                                VARCHAR2(9)
 SAL                                                NUMBER
 COMM                                               NUMBER

Query 1 shows the problem with a numeric column and Query 2 shows it working with a character column.

How do I make numeric predicates execute on the Oracle database?

Thanks,
Dan.
0
Comment
Question by:wrfrogman
  • 4
  • 3
8 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 9815758
Have you tried to use OPENQUERY?  Maybe not quite as convenient as using the linked server syntax directly, but it's pretty close to executing a passthru query.

Brett
0
 
LVL 1

Author Comment

by:wrfrogman
ID: 9815804
OPENQUERY works fine, but I can't use it in my application because it would require changing client code.
0
 
LVL 34

Accepted Solution

by:
arbert earned 250 total points
ID: 9815836
Well, you're kind of at the mercy of the OLE DB provider then.  It's deciding on what it thinks it can accurately pass to the remote server and it will process locally anything that it thinks it couldn't pass.

Other options, stored proc (client code change), openquery (client code change).  I know it's not the best, but have you tried the non-microsoft Oracle driver?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:wrfrogman
ID: 9816225
The Oracle provider for OLEDB version 9.2.0 does the same thing.
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 9816468
Hi wrfrogman,

just a thought ,
have you tried making it explicit that your querying a number?

i.e.
where comm = 5.00

or declare a number/decimal  and pass that?




Cheers!
0
 
LVL 1

Author Comment

by:wrfrogman
ID: 9821979
Good thought Lowfatspread, but unfortunately didn't do the trick.

Further investigation has revealed that if the Oracle column has a length, precision and scale defined, then it does work, otherwise not.  This unfortunately rules out all of the SEQNOs in my database.
0
 
LVL 34

Expert Comment

by:arbert
ID: 9822057
What if you try to run the query against a view instead?
0
 
LVL 1

Author Comment

by:wrfrogman
ID: 10628937
I've found no evidence that it can be made to work, so I guess arbert's answer is the closest.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question