Solved

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

Posted on 2003-11-24
8
615 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

728 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