Solved

oracle number or rows returned

Posted on 2004-10-08
7
335 Views
Last Modified: 2013-12-12
does anyone know how to get the number of records returned from a select query the usual things like ocirowcount only tell you the number of affected rows in an update query etc not in a select query

0
Comment
Question by:andrew67
  • 3
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 125 total points
ID: 12256906
You will only get the number after you fetched all neccesary records (but then you could count the rows also :-( )
I don't know of any method that can do this efficient without running the query twice.

$rows =  Select count(*) from (<your SQL-Statement>) (so it is emulated in pear DB)

See:
http://de2.php.net/ocirowcount
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12256933
this?

$rows = ora_numrows (resource cursor)
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12256943
$rows = ora_numrows ($put_your_resource_cursor_here);
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12257069
@minichicken
The ora_numrows will only tell you how many rows you have fetched already. You will only get the correct result after you fetched all records. If you fetched 5 record ora_numrows will return 5, after you fetch another 5 rows it will return 10, ...

the Oracle 7 - functions should no longer be used as they are not realy supported and as andrew67 stated hi is aready using the oci8 interface (ocirowcount)
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12257091
hmm... alright, thanks for the info :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now