[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2003-11-24
8
Medium Priority
?
640 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 500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

650 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