Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 9th, 2013, 04:22 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How 2 point ref cursor to FOR Cursor loop results

Hi All,
It's really great to see every example under the sun found by google using DBMS_OUTPUT.PUTLINE() as the sole action taken on the results of each iteration of a loop, not too useful beyond the dev stage, though.
What I want is to simply report on the results of the LOOP below.
Each line sent to DBMS_OUTPUT should instead be in some form where I can point a single REF CURSOR to all of them. I simply need to output every line to a report on an ASP.NET web server. I want to do this the most efficient way possible. If that means inserting into a temp table, then selecting that resultset into a ref cursor, so be it. If not, please enlighten me. Thanks

DECLARE
vGroup NUMBER := 1;
vIter NUMBER :=1;

CURSOR cur IS
SELECT LID, SID, Cnt, Limits, Iter
FROM (
SELECT LID, SID, COUNT(*) OVER (PARTITION BY LID) Cnt, TRUNC(COUNT(*) OVER (PARTITION BY LID)/4)*4 Limits,
row_number() over (partition by LID order by SID desc) iter
FROM VW_TA
WHERE C0 > 0 AND C1 > 0 AND C2 > 0 AND C3 > 0 ORDER BY LID, SID DESC
) a WHERE ITER <= LIMITS;

BEGIN
FOR aRec IN cur
LOOP


DBMS_OUTPUT.PUT_LINE(aRec.LID || ', ' || aRec.SID || ', ' || aRec.Cnt || ', ' || aRec.Limits || ', ' || vGroup || ', ' || vIter);
IF (vIter = 4) THEN
vIter := 1;
vGroup := vGroup + 1;
ELSE
vIter := vIter +1;
END IF;
END LOOP;
END;
  #2 (permalink)  
Old July 9th, 2013, 04:28 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Reason why I am asking this is it seems the only way to get data from a stored procedure in oracle to a .NET dataset is via REF CURSOR. I am having a hard time figuring out how to get my resultant data into (or, view-able by) a ref cursor. If it were a simple select statement it wouldn't be an issue as I could then open the ref cursor for that select statement. Because I need to do some setting of variables in a for loop first, it is not a simple select statement.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
For loop with Floating Point Loop Counter - pp. 150 shivesh BOOK: Ivor Horton's Beginning Visual C++ 2010 1 March 28th, 2012 09:31 AM
Should I use a cursor? RobCarter SQL Server 2000 10 June 24th, 2011 09:25 AM
Problem with CURSOR FOR LOOP code_lover Oracle 12 April 9th, 2009 04:42 PM
Cursor results to Dataset NinaWilliam ADO.NET 0 November 27th, 2008 03:26 AM
Magnetic Cursor - Target Area Cursor? gcarcass .NET Framework 2.0 1 May 5th, 2008 07:20 AM



All times are GMT -4. The time now is 07:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.