Solved

oracle number or rows returned

Posted on 2004-10-08
7
338 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 dynamically set the form action using jQuery.

785 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