Solved

oracle number or rows returned

Posted on 2004-10-08
7
333 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
Comment Utility
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
Comment Utility
this?

$rows = ora_numrows (resource cursor)
0
 
LVL 12

Expert Comment

by:minichicken
Comment Utility
$rows = ora_numrows ($put_your_resource_cursor_here);
0
 
LVL 48

Expert Comment

by:hernst42
Comment Utility
@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
Comment Utility
hmm... alright, thanks for the info :)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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…
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 look for a specific file type in a local or remote server directory using PHP.

771 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

14 Experts available now in Live!

Get 1:1 Help Now