Solved

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

Posted on 2003-11-24
8
593 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
 
LVL 1

Author Comment

by:wrfrogman
ID: 9816225
The Oracle provider for OLEDB version 9.2.0 does the same thing.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Suggested Solutions

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now