Forum Stats

  • 3,816,057 Users
  • 2,259,134 Discussions
  • 7,893,374 Comments

Discussions

Linked Server Query with EXEC () AT

915593
915593 Member Posts: 1
edited Feb 7, 2012 2:00AM in Oracle Provider for OLE DB
Hi Folks,

I am facing some issue .The scenario is like this : I've created a LINKED SERVER in SQL Server 2005
to connect to ORACLE database(so far so good) .After that i had to call their Stored Procedures, in which i was facing some problems.
So i decided to create stored procedures in SQL with the script similar to what the Oracle Stored Procedure looks like.
I used EXEC (' ') AT <SERVER NAME> syntax to create the SP. The main issue is the WHERE clause which is illustrated below

SYNTAX in SQL SP
----------------
WHERE (LOG_FUN_ID =? OR LOG_FUN_ID=NULL)
AND (LOG_STATUS_CODE=? OR LOG_STATUS_CODE=NULL)
AND (LOG_CHNL_ID=? OR LOG_CHNL_ID=NULL)
AND (T1.LOG_CREATION_TMSTMP LIKE ? || ''%'' OR T1.LOG_CREATION_TMSTMP=NULL)
AND (T1.LOG_CREATION_TMSTMP LIKE ? || ''%'' OR T1.LOG_CREATION_TMSTMP=NULL)

group by LOG_FUN_ID,LOG_STATUS_CODE

',
@LOG_FUN_ID,@LOG_STATUS_CODE,@LOG_CHNL_ID,@LOG_CRET_FRM,@LOG_CRET_TO) AT <servername>


----------------------------------------

SYNTAX in ORACLE SP
-------------------

WHERE (LOG_CREATION_TMSTMP >= to_timestamp(p_LOG_CRET_FRM, 'DD-MM-YYYY HH24:MI:SS') or p_LOG_CRET_FRM is null)
AND (LOG_CREATION_TMSTMP < to_timestamp(p_LOG_CRET_TO, 'DD-MM-YYYY HH24:MI:SS') or p_LOG_CRET_TO is null)
AND (LOG_CHNL_ID = p_LOG_CHNL_ID or p_LOG_CHNL_ID is null)
AND (LOG_FUN_ID = p_LOG_FUN_ID or p_LOG_FUN_ID is null)
AND (LOG_STATUS_CODE like p_LOG_STATUS_CODE ||'%' or p_LOG_STATUS_CODE is null)

group BY log_fun_id,log_status_code ;

The parameters are preceded by "p" in the above Oracle script.


So the SQL Script is not returning any records even though data is present in Oracle DB.

Edited by: 912590 on Feb 6, 2012 11:00 PM
This discussion has been closed.