[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 654
  • Last Modified:

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

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
wrfrogman
Asked:
wrfrogman
  • 4
  • 3
1 Solution
 
arbertCommented:
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
 
wrfrogmanAuthor Commented:
OPENQUERY works fine, but I can't use it in my application because it would require changing client code.
0
 
arbertCommented:
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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
wrfrogmanAuthor Commented:
The Oracle provider for OLEDB version 9.2.0 does the same thing.
0
 
LowfatspreadCommented:
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
 
wrfrogmanAuthor Commented:
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
 
arbertCommented:
What if you try to run the query against a view instead?
0
 
wrfrogmanAuthor Commented:
I've found no evidence that it can be made to work, so I guess arbert's answer is the closest.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now