473,804 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored procedure that returns a recordset?

I have a VB program that calls stored procedures in MS SQL Server that
deliver a recordset. I need to do the same thing with Oracle. Following is
a simple SQL Server procedure that does this. How do I do that with Oracle?
CREATE PROCEDURE dbo.sp_Level1
@ClientDB varchar (30) = NULL,
@LevelID1 varchar (8) = NULL

AS
BEGIN
Select * from tblLevel1
where active='Y' and ClientDB=@Clien tDB
order by DisplayOrder
END

return (0)

END

Jul 19 '05 #1
5 13945
Based on 0040 (Oracle Object for OLE)(i only use M$ stuff for GUI
things...and only when I have to)

You will have VB call the stored procedure to pass a "ref cursor"
parametr back.

--- The st. procedure need to be in a package. ---

create or replace package foo
as
type rcur is ref cursor ;
procure rctest (p_rc in out rcur, p_table in varchar2 default 'emp') ;
end;

create or replace package body foo
as
procure rctest (p_rc in out rcur, p_table in varchar2 default 'emp')
is
l_dynamic_sql varchar2(1000) := 'select * from ' || p_table ;
begin
open p_rc for select * from emp; --< Open a static sql
/*
open p_rc for l_dynamic_sql ; --< Open a dynamic sql build on the
fly

*/
end rctest;

end;
I have a VB program that calls stored procedures in MS SQL Server that
deliver a recordset. I need to do the same thing with Oracle. Following is
a simple SQL Server procedure that does this. How do I do that with Oracle?
CREATE PROCEDURE dbo.sp_Level1
@ClientDB varchar (30) = NULL,
@LevelID1 varchar (8) = NULL

AS
BEGIN
Select * from tblLevel1
where active='Y' and ClientDB=@Clien tDB
order by DisplayOrder
END

return (0)

END

Jul 19 '05 #2
On 16 Aug 2003 12:08:34 -0700, rc***@panix.com (Robert C) wrote:
procure rctest (p_rc in out rcur, p_table in varchar2 default 'emp') ;


Pretty much, but I'd recommend making the output cursor the last
parameter in the procedure. IIRC, ADO or OLE-DB has some problem with
procedure calls where there are more than two parameters, where one of
those is an output ref cursor, and it isn't the last one.

Also note, if you call the procedure by creating an ADO.Command object
and appending Parameter objects, don't create one for the output ref
cursor.

cheers,
Ross.
--
Ross McKay, WebAware Pty Ltd
"Since when were you so generously inarticulate?" - Elvis Costello

Jul 19 '05 #3
On 16 Aug 2003 12:08:34 -0700, rc***@panix.com (Robert C) wrote:
--- The st. procedure need to be in a package. ---


Oh, and whilst I reckon that packages are the way to go in Oracle, if
you prefer, you can define your stored procedures as normal. You will
need to create (at least) one package, however, to define a type for the
reference cursor.

Personally, I'd put all procedures and functions into packages. But one
reason I can think of for not doing that, is if you are using Microsoft
tools like Visual Studio .NET, Visual Interdev or (shudder) the Data
environment in VB to edit your stored procedures - MS tools don't know
what Oracle packages are.

cheers,
Ross.
--
Ross McKay, WebAware Pty Ltd
"Since when were you so generously inarticulate?" - Elvis Costello

Jul 19 '05 #4
On 16 Aug 2003 12:08:34 -0700, rc***@panix.com (Robert C) wrote:
>procure rctest (p_rc in out rcur, p_table in varchar2 default 'emp') ;
Pretty much, but I'd recommend making the output cursor the last
parameter in the procedure. IIRC, ADO or OLE-DB has some problem with
procedure calls where there are more than two parameters, where one of
those is an output ref cursor, and it isn't the last one.

Also note, if you call the procedure by creating an ADO.Command object
and appending Parameter objects, don't create one for the output ref
cursor.

cheers,
Ross.
--
Ross McKay, WebAware Pty Ltd
"Since when were you so generously inarticulate?" - Elvis Costello

Jun 27 '08 #5
On 16 Aug 2003 12:08:34 -0700, rc***@panix.com (Robert C) wrote:
>--- The st. procedure need to be in a package. ---
Oh, and whilst I reckon that packages are the way to go in Oracle, if
you prefer, you can define your stored procedures as normal. You will
need to create (at least) one package, however, to define a type for the
reference cursor.

Personally, I'd put all procedures and functions into packages. But one
reason I can think of for not doing that, is if you are using Microsoft
tools like Visual Studio .NET, Visual Interdev or (shudder) the Data
environment in VB to edit your stored procedures - MS tools don't know
what Oracle packages are.

cheers,
Ross.
--
Ross McKay, WebAware Pty Ltd
"Since when were you so generously inarticulate?" - Elvis Costello

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4522
by: Vitamin | last post by:
I have written a stored procedure which will paging the recordset, and return a range of record that i need, and i write a asp code to call it however, no any return after the set objRs = objCmd.Execute when i try to Response.write (objRs.recordcount) it said the recordset is close.... how can i solve this problem?? thx ====================
15
6017
by: Jarrod Morrison | last post by:
Hi All Im generally a vb programmer and am used to referencing multiple records returned from a query performed on an sql database and im trying to move some functions of my software into sql stored procedures. So far ive been able to move the functions relatively easily but im unsure about how to output multiple values from an sql stored procedure. By this i mean for example one of the stored procedures may take your username and return...
4
3303
by: Jarrod Morrison | last post by:
Hi All Im using a stored procedure on my sql server and am unsure of the syntax that i should use in it. Im pretty sure that there is a way to do what i want, but as yet i havent been able to find much info on it. Basically the procedure takes the machinename and username supplied and searches a table or two for some matches and this part works great. The only problem i have is that with the app that ties in with the procedure returns...
1
1684
by: Eugene Anthony | last post by:
Method 1: set rs = Server.CreateObject("ADODB.Recordset") objConn.usp_RetrieveCategories rs Method 2: set rs = objConn.Execute("usp_RetriveCategories") Which method is considered to efficient. Is it method 1 or method 2?.
2
11711
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. tCetecM1CUST (SQL Table that contains the Customer Information) tAccountingDetail (SQL Table that contains the information in the form) frmAccountingEntry (Access form used to enter data) spGetCustomerInformation (Stored Procedure which returns data using...
6
6768
by: Wojciech Wendrychowicz | last post by:
Hello to All, I'm trying to retrieve records from AS/400 in an VBA application. So, I've made an RPG program, then a stored procedure wchich calls that RPG program, and finally some VBA code to call the stored procedure and retrieve data from AS/400. The problem is, that when I finally run my VB code, it just hangs. But when I call the same stored procedure from "pure" SQL - it works perfect. (I evaluate Aqua Data Studio 3.7) What I...
12
17673
by: Scott | last post by:
Front-end Access 2000 I have a stored procedure that has 2 parameters BusinessUnitID and Year. It returns multiple record sets (5 to be exact). I thought I could use a Pass through query but that only returns the first record set. I thought I could use ADO but that does not seem to work. I get an Error
1
11321
by: stjulian | last post by:
I have a stored procedure which returns 2 tables and 1 output value. I want the first table to be assigned to rs1 and the second to rs2. However when I run this, I get the following error as I begin to refer to the rs2 recordset (Do while not rs2.eof). I have even used 2 ".execute" statements in the code below, but the code assigns the first recordset twice. Microsoft VBScript runtime error '800a01a8' Object required: 'rs2' ...
2
2632
by: =?Utf-8?B?YW5vb3A=?= | last post by:
Hello, I have a stored procedure named as usp_CheckLogin with two parameters as @usID, @Password also values of these parameters are to be extracted using Request.Form from the fields in the forms. Now How do I call this stored procedure from an ASP Page using a Connection object in Server Tags <% %>. Also this stored
4
17409
by: stjulian | last post by:
(IIS 6.0, SQL Server 2000) I have a block of code that populates a recordset from a stored procedure. The problem is, the recordset seems to be forward only (which would be OK), but can't jump with the "AbsolutePage" property (which isn't OK) How do I define the recordset that will allow this? Julian
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.