On Wed, 2 Apr 2003 16:17:20 -0500 Veera Prasad <[EMAIL PROTECTED]> wrote:
>
> #!/bin/perl -w
> use DBI;
> my $db = $ARGV[0];
> my $rows;
> my $dbh = DBI->connect( "dbi:Oracle:$db", "vprasad", "vprasad" )
> or die "Can't connect to Oracle database: $DBI::errstr\n";
> my $stamt = $dbh->prepare("select * from ab_tran");
> $stamt->execute();
It is risky to execute() without checking for success. Either set
$dbh -> {RaiseErrors} to 1 before prepare()ing, or check each call.
> $rows = $stamt->fetchrow_array(); --- without using this function
> print "rows: $rows\n";
Read the fine DBI manual to find out what fetchrow_array() returns
in a scalar context.
http://trantor.jsbsystems.com/DBI-FAQ/49.html
> $stamt->finish;
> $dbh->disconnect
> or warn "Disconnection failed: $DBI::errstr\n";
>
> Without using the function 'fetchrow_array()' , is there any better way
> to get count of number of rows for a select st.
No the best way is to count them as you fetch them. The fetch*()
methods only fetch a single row, so you'll need a loop.
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.