|
|
 |
| SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

July 1st, 2004, 12:14 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Calling Oracle Stored Procedure using Linked Serve
I have a linked server to oracle, I will have to call an oracle stored procedure from SQL Server.
Any Ideas on this??
Regards
Twinkle
__________________
Warm Regards From,
Twinkle
************************************************** *******************
I don\'t know the key to success, but the key to failure is trying to please everybody.
************************************************** *******************
|

July 1st, 2004, 12:39 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Unlink them.
Create the SP in Oracle.
Call the SP through the ADO.NET driver to Oracle.
the oracle client must be installed (and configured) on the machine you wish to talk to oracle with.
That's all I know- my Oracle DBA actually set it up for me when I needed it.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|

July 2nd, 2004, 01:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,477
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am not good at that, just took that from a site on searching for that info. See if that helps.
How do you execute stored procedures in Oracle9i from MS SQL Server 2000? Is it possible?
It is possible, but you have a little bit of work to do. First, you'll probably want to visit SQL Server's documentation. For SQL Server 2000, fire up Books Online and choose the Index tab. In the search box, search for the 'heterogeneous data sources, distributed queries' entry. This will give you all the information, or links to the information, on how to set up SQL Server to access data in a non-SQL server (i.e. Oracle) environment. What this doesn't tell you is how to execute a stored procedure. The easiest way I know how to execute an Oracle stored procedure from SQL Server is to change the stored procedure in Oracle to a function. This is pretty easy to do. Use the same PL/SQL block that defines the stored procedure and create a function that returns TRUE at the very end. You can have the function return other values depending on the success of the stored procedure code. Or, have the function just call the stored procedure and return some value. Once you have it in a function, then you'll just have SQL Server run a distributed query which does the following:
SELECT my_function FROM dual
In running this query, the function will execute the stored procedure's code and the output value will be returned to SQL Server. You may or may not care what this value is. Just performing the above SELECT is enough to execute the code.
Also check this URL, if that helps too.
Linked Severs on MS SQL Part 4, Oracle
Cheers!
_________________________
- Vijay G
Strive for Perfection
|

July 6th, 2004, 05:02 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yeah, we have called the stored procedure as a function, It is working fine now.Thanks Everyone
|

September 23rd, 2009, 05:02 AM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
call linked oracle procedure
call oracle procedure (function) via linked server and get its result (return value)
Code:
--input parameters p1, p2, p3
declare @SQL nvarchar(1000)
declare @param nvarchar(100)
declare @result varchar(20) -- numbers may cause data type error
-- (...custom actions, i.e. insert to local table)
set @SQL = N'set @result = (select * from openquery(myLinkedServer, ''select OwnerName.Function_Insert(' + cast(@p1 as varchar) + ', ' + cast(@p1 as varchar) + ', ' + cast(@p3 as varchar) + ') from dual''))'
set @param = '@result varchar output'
EXEC sp_executesql @SQL, @param, @result output
if @result <> '0' goto ERROR
-- (...custom actions)
return 1 -- OK
ERROR:
-- (...custom actions, i.e. delete from local table with(rowlock))
return 0 -- KO
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |