473,416 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Multiple Recordset from a Stored Procedure

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

When I change the SQL from SQL = "procIPCReport " & i & ", " &
txtYear.Value
To
SQL = "select * FROM tblBudget

It opens and works

The reason I cannot use multiple calls to the database is the last 4
record sets are generated from the information in the first record set.
The procedure can take 5 minutes to generate results so going back to
the server is not an option.

So my question is I need either 5 different record sets or 1 record set
containing multiple record sets

How should I accomplish this?

Dec 7 '05 #1
12 17598
You have a SPROC that returns five recordsets?

And ADO does not seem to work?

OK. I confess that I have not seen a SPROC that returns five
recordsets, or even two.

Secondly ADO works. When there's an error it's because someone made an
error.

I'm guessing you need five different recordsets. I'm thinking you get
them by getting the first recordset in ADO, selecting from it the
values needed to define the others and using them to get the other
four.

I'd start with

Dim r(5) as ADODB.Recordset

Set r(0) = CurrentProject.Execute("Whatever")

' get value from r(0); I'm assuming these are parameters?
' use the values to for

Set r(1) = CurrentProject.Execute("Whatever Wherever");

etc

Dec 7 '05 #2
I had a problem in the SPROC I forgot to SET NOCOUNT ON

In ADO however when return multiple recordsets you loop through the
recordet something like this

SET Rst = Connection.Execute(procMultipleRst)

doWhatever1 Rst

SET Rst = Rst.NextRecordset
doWhatever2 Rst

SET Rst = Rst.NextRecordset
doWhatever3 Rst

etc

Works great when loading a form with many different list only requires
one call to the database
Note: Rst 2 to N are Readonly Forward Only recordsets


*** Sent via Developersdex http://www.developersdex.com ***
Dec 8 '05 #3
I see; sounds like a great capability.

Dec 8 '05 #4
Lyle,
It's also useful for things such as invoices.

You can make one call and get the header and details back, you access the
details using the Nextrecordset method. This is most useful in unbound mode
I find.

I tend to do something like (in VB not Access)

Dim varHead as Variant
Dim varDets as Variant
DIm rs as adodb.Recordset

' code to open the recordset

varHead = rs.GetRows
set rs = rs.NextRecordset
varDets = rs.GetRows

' do the rest of the work

(That's all air code so don't rely on it)

This way you end up with a couple of arrays holding your data which are then
faster to iterate through to carry out unbound data assignment etc., you end
up with an app which is so fast it's blinding.
--
Terry Kreft

"Lyle Fairfield" <ly***********@aim.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I see; sounds like a great capability.

Dec 8 '05 #5
Terry Kreft <te*********@mps.co.uk> wrote:
: Lyle,
: It's also useful for things such as invoices.

: You can make one call and get the header and details back, you access the
: details using the Nextrecordset method. This is most useful in unbound mode
: I find.

: I tend to do something like (in VB not Access)

: Dim varHead as Variant
: Dim varDets as Variant
: DIm rs as adodb.Recordset

: ' code to open the recordset

Can you please explain, not simply show code, the essence of
opening a recordset so that it apparently becomes a set of
recordsets, not a single continuous set of rows? I tried to
read Microsoft's documentation for NextRecordSet, but I'm afraid
that I didn't understand...(I also have never looked at VB without
Access, so this parenthesis just alerts you to my discomfort
with yours)
thanks, --thelma
: Terry Kreft
Dec 8 '05 #6
Say you have a stored procedure in SQL Server which looks like this

Create Procedure Invoice
@InvNum char(10)
AS
SET NOCOUNT ON
-- Return the invoice header data
SELECT
c.name,
c.address1,
c.address2,
c.address3,
c.address4,
h.*
FROM
inv_head h
INNER JOIN
customers c
ON
h.customer = c.customer
WHERE
h.inv_num = @InvNum

-- Return the invoice details data
SELECT
*
FROM
inv_dets d
WHERE
d.inv_num = @InvNum
SET NOCOUNT OFF

Note the stored procedure returns two recordsets.

If you then open an ado recordset using the above stored procedure the
recordset will hold the invoice header data, using the NextRecordset method
then populates the recordset with the invoice details data.
--
Terry Kreft

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:dn**********@uwm.edu...
Terry Kreft <te*********@mps.co.uk> wrote:
: Lyle,
: It's also useful for things such as invoices.

: You can make one call and get the header and details back, you access
the
: details using the Nextrecordset method. This is most useful in unbound
mode
: I find.

: I tend to do something like (in VB not Access)

: Dim varHead as Variant
: Dim varDets as Variant
: DIm rs as adodb.Recordset

: ' code to open the recordset

Can you please explain, not simply show code, the essence of
opening a recordset so that it apparently becomes a set of
recordsets, not a single continuous set of rows? I tried to
read Microsoft's documentation for NextRecordSet, but I'm afraid
that I didn't understand...(I also have never looked at VB without
Access, so this parenthesis just alerts you to my discomfort
with yours)
thanks, --thelma
: Terry Kreft

Dec 8 '05 #7

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:bf********************@karoo.co.uk...
Say you have a stored procedure in SQL Server which looks like this


I am absolutely intrigued by this technique. Seems to me that it might
provide a substantial performance benefit. Any chance you might know where
I can find an example that uses an SP in Oracle to create multiple
recordsets like that?

Randy Harris

Dec 8 '05 #8
I'm sorry but I don't.

I wouild have thought a search on something like "Oracle Multiple
Recordsets" would return some results.
--
Terry Kreft

"Randy Harris" <ra***@SpamFree.com> wrote in message
news:e6****************@newssvr11.news.prodigy.com ...

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:bf********************@karoo.co.uk...
Say you have a stored procedure in SQL Server which looks like this


I am absolutely intrigued by this technique. Seems to me that it might
provide a substantial performance benefit. Any chance you might know
where
I can find an example that uses an SP in Oracle to create multiple
recordsets like that?

Randy Harris

Dec 8 '05 #9

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:eu********************@karoo.co.uk...
I'm sorry but I don't.

I wouild have thought a search on something like "Oracle Multiple
Recordsets" would return some results.
--
Terry Kreft


Thanks very much Terry. I searched on that very phrase (43,000 hits).

Randy Harris

Dec 8 '05 #10

So you'll pop back in about 20 years and let us know how your research went
then ?

<BG>

--
Terry Kreft

"Randy Harris" <ra***@SpamFree.com> wrote in message
news:Gs******************@newssvr14.news.prodigy.c om...

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:eu********************@karoo.co.uk...
I'm sorry but I don't.

I wouild have thought a search on something like "Oracle Multiple
Recordsets" would return some results.
--
Terry Kreft


Thanks very much Terry. I searched on that very phrase (43,000 hits).

Randy Harris

Dec 9 '05 #11
I know zip about Oracle and zip + 1 / infinity about multiple
recordsets but I am so interested that I couldn't resist the search
myself:

I came upon:
http://www.oracle.com/technology/sam...db8/index.html
Returning multiple recordsets from a stored procedure[13-Mar-2003]
This sample shows how to return multiple recordsets from database
stored procedure using ActiveX Data Objects (ADO) with VB
Download Now (ZIP, 103KB)

Also I note that ADO help suggests that we can roll our own multiple
recordset returning command as:
"If you open a Recordset object based on a compound command statement
(for example, "SELECT * FROM table1;SELECT * FROM table2") using the
Execute method on a Command or the Open method on a Recordset, ADO
executes only the first command and returns the results to recordset.
To access the results of subsequent commands in the statement, call the
NextRecordset method."

And I experimented with MS-SQL as follows:

Dim r As ADODB.Recordset
Dim r2 As ADODB.Recordset
Set r = CurrentProject.Connection.Execute( _
"SET NOCOUNT ON " _
& "SELECT * FROM FFDBATransactions " _
& "COMPUTE AVG(TotalAmount)")
Set r2 = r.NextRecordset
Debug.Print r.GetString(adClipString, 1, vbTab, vbNewLine)
Debug.Print r2.GetString(adClipString, 1, vbTab, vbNewLine)
Set r = Nothing
which gives:

1 2004-01-01 Carryover from 2003 7290.07 17 1 11

591.5508

And I'm going to ask a question about multiple recordsets and no count
in a separate thread.

Dec 9 '05 #12

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:_b********************@karoo.co.uk...

So you'll pop back in about 20 years and let us know how your research went then ?

<BG>

--
Terry Kreft


I downloaded some sample code from Oracle. So far I haven't gotten it
working (OLEDB driver issue), but I hope to. I'll report back as soon as
I've got something working.

Randy

Dec 9 '05 #13

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

Similar topics

2
by: sbw | last post by:
Hi. I have an app which uses multiple databases and I would like to know if there is a way to connect to different databases through OLEdb (or any other connection string) which allows me to...
5
by: Eugene Anthony | last post by:
I have created the following stored procedure whereby it will check whether the categoryID is valid and if it is then the updation will be performed, else a -1 will be returned. This procedure will...
2
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. ...
3
by: Suresh | last post by:
Hi All I am writing Import\Export routine in DB2 using stored procedure and front end as JAVA. For this I have two option 1) Writing five different stored procedure returning one cursor...
0
by: Hades5k | last post by:
Hello everyone, I'm working a project using MS Project 2003 database. What I need to do is to get all entries for a specific user, from a specific project with specific citerias. Its a web...
1
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...
6
by: binky | last post by:
Hi folks, I'm just learning how to use MS Access as a front end for SQL Server, and have a question: I have a stored procedure that returns a set of records from a SQL Server and loads it into a...
3
by: Dooza | last post by:
Hi there, I have a Stored Procedure in SQL 2000 that takes 10 input paremeters, and outputs 11 recordsets, not rows, but 11 different SELECT statements. The purpose of this is to for a menu...
6
by: SethM | last post by:
I have a stored procedure that returns a record set. I want to functionalize this so I can have multiple presentations of the same record set. However, I can not get rs_event.open StoreProc to pass...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...

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.