Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 1st, 2004, 11:14 AM
Authorized User
 
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
************************************************** *******************
 
Old July 1st, 2004, 11:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
 
Old July 2nd, 2004, 12:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old July 6th, 2004, 04:02 AM
Authorized User
 
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, we have called the stored procedure as a function, It is working fine now.Thanks Everyone

 
Old September 23rd, 2009, 04:02 AM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
calling stored procedure jomet JSP Basics 0 November 23rd, 2007 08:06 AM
calling an oracle procedure from a jsp page jasonteaboy Pro JSP 0 November 20th, 2006 03:06 PM
Calling an Oracle Stored Procedure booksnore2 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 October 1st, 2004 09:35 AM
Calling Oracle Stored Procedures booksnore2 General .NET 0 August 24th, 2004 02:08 PM
CALLING ORACLE SELECT PROCEDURE danielwajnberg Oracle 1 November 20th, 2003 09:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.