Home All Groups Group Topic Archive Search About

How to send variable to Oracle in a distributed query

Author
6 Jan 2006 10:06 PM
Cindy Winegarden
Hi All,

I'm working on a distributed query that connects two SQL Servers and an
Oracle 10 data warehouse. I'd like to send a date variable in the WHERE
clause of the the Oracle SQL string to replace the hard coded dates I'm
using to test. Here's what my test code looks like:


Declare @BeginDateOfService DateTime
Declare @EndDateOfService DateTime

Set @BeginDateOfService = '20050101'
SEt @EndDateOfService = '20051231'


Select  .......
From
DUMC_QualityMeasures_BMI2 Pd
Inner Join [SQLServer1].Database1.dbo.Patient_Fsc_FollowUp Pff On
Pd.MemberID = Pff.Certificate_Number
Inner Join [SQLServer1].Database1.dbo.Patient_Fscs Pf On Pff.Patient_ID =
Pf.Patient_ID And Pff.ID_19 = Pf.ID_19
Inner Join [SQLServer1].Database1.dbo.Patient P On Pf.Patient_ID =
P.Patient_ID
Left Join OpenQuery(OracleServer,
   'Select  /*+ NOPARALLEL (Pt) */
    ....
   From ....
   Where
    D.Day Between To_Date(''20050101'', ''YYYYMMDD'') And
To_Date(''20051231'', ''YYYYMMDD'')
   ') Dsr On P.Medical_Record_Number = Dsr.Medical_Record_Number
Left Join BMITable Bt On ....

Where .......
Group By  ....
Having ....

Thanks in advance!

--
Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP
cindy_winegar***@msn.com  www.cindywinegarden.com

AddThis Social Bookmark Button