10-14-2008
Will the below part of code provide me an error message if the $sth->fetchrow_array( ) fails for any reason? Is there any way to know the data (@row) for which the $sth->fetchrow_array( ) has failed?
Ikon what i need to know is chich row is not returned..
while ( @row = $sth->fetchrow_array( ) ) {
print "Row: @row\n";
}
warn "Data fetching terminated early by error: $DBI::errstr\n"
if $DBI::err;
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello,
I am a newborn baby to Unix and I was told that it was possible to have Microsoft Access databases on a Unix web server. I am using Perl to interface and query the Access database, which puts the information into the appropriate fields of a web page. Then updated information is submitted... (1 Reply)
Discussion started by: spiderling
1 Replies
2. Programming
Hey,
I want to access oracle database through Unix C programming.. Can you through me some light on that... (5 Replies)
Discussion started by: kavi
5 Replies
3. Shell Programming and Scripting
Hi,
I tried to run this code but it isnt giving me any output or errors.
My aim is to retrieve the row based on the flag name(this is the primary key).
flag_test is my table
This is how i ran it:
perl read_db.pl flag1
flag1 is the criteria in where clause
--------
this is my... (2 Replies)
Discussion started by: mercuryshipzz
2 Replies
4. UNIX for Advanced & Expert Users
Hi!
I need to access two diferent databases allocated in a linux server through PHP. I know in the php.ini file I can't configure some parameters as odbc.default_db... but I can't configure it.
I've already installed unixodbc drivers
Can Anybody point me to a tutorial web o teach me how... (0 Replies)
Discussion started by: ncatdesigner
0 Replies
5. Shell Programming and Scripting
Hi
i have the following code:
if(($line!=1) and (@field!='\$')){
print ( "\nTRY TO CONNECT TO DATABASE................\n");
my $dbh = DBI->connect($dsn, $user, $pass);
print ("CONNECTED TO DATABASE\n");
eval
... (1 Reply)
Discussion started by: chriss_58
1 Replies
6. Shell Programming and Scripting
hi guys,
I am using the following code in order to access a database.
#!/usr/bin/perl
print "READ DATA FROM DATABASE\n";
use DBI;
use strict;
#use DBD::Oracle;
my $user='reassure';
my $pass='R3Assur3';
#my $dsn="dbi:Oracle:orcl";
my $dsn='dbi:Oracle:cobscs.world';
my $dbh =... (1 Reply)
Discussion started by: chriss_58
1 Replies
7. IP Networking
Hi! :D
I'm new here, and I will appreciate all the help you can give.
This is the problem we are trying to solve at my office.
At office 1 we have SCO UNIX 5.0.can't remember last number. On it runs database software on which we input/read/modify data throughout terminal software, on remote... (1 Reply)
Discussion started by: PNemesis
1 Replies
8. Shell Programming and Scripting
i want to access database (sql script) within a unix script.
help me (2 Replies)
Discussion started by: chamaraa
2 Replies
9. UNIX for Dummies Questions & Answers
Hello all,
is it possible to write a script in order to connect to a database, load data in a specific domain and execute the corresponding command? (3 Replies)
Discussion started by: FelipeAd
3 Replies
10. AIX
Hi,
I am running a JDBC:ODBC code to access .mdb file in my windows system successfully but, not able to access MS Access mdb file in AIX Unix box. when I am trying to run the same piece of code in AIX Unix box it is saying "No Suitable Driver". I need some immediate help. (0 Replies)
Discussion started by: thirunp
0 Replies
LEARN ABOUT DEBIAN
dbix::contextualfetch
DBIx::ContextualFetch(3pm) User Contributed Perl Documentation DBIx::ContextualFetch(3pm)
NAME
DBIx::ContextualFetch - Add contextual fetches to DBI
SYNOPSIS
my $dbh = DBI->connect(...., { RootClass => "DBIx::ContextualFetch" });
# Modified statement handle methods.
my $rv = $sth->execute;
my $rv = $sth->execute(@bind_values);
my $rv = $sth->execute(@bind_values, @bind_cols);
# In addition to the normal DBI sth methods...
my $row_ref = $sth->fetch;
my @row = $sth->fetch;
my $row_ref = $sth->fetch_hash;
my %row = $sth->fetch_hash;
my $rows_ref = $sth->fetchall;
my @rows = $sth->fetchall;
my $rows_ref = $sth->fetchall_hash;
my @tbl = $sth->fetchall_hash;
DESCRIPTION
It always struck me odd that DBI didn't take much advantage of Perl's context sensitivity. DBIx::ContextualFetch redefines some of the
various fetch methods to fix this oversight. It also adds a few new methods for convenience (though not necessarily efficiency).
SET-UP
my $dbh = DBIx::ContextualFetch->connect(@info);
my $dbh = DBI->connect(@info, { RootClass => "DBIx::ContextualFetch" });
To use this method, you can either make sure that everywhere you normall call DBI->connect() you either call it on DBIx::ContextualFetch,
or that you pass this as your RootClass. After this DBI will Do The Right Thing and pass all its calls through us.
EXTENSIONS
execute
$rv = $sth->execute;
$rv = $sth->execute(@bind_values);
$rv = $sth->execute(@bind_values, @bind_cols);
execute() is enhanced slightly:
If called with no arguments, or with a simple list, execute() operates normally. When when called with two array references, it performs
the functions of bind_param, execute and bind_columns similar to the following:
$sth->execute(@bind_values);
$sth->bind_columns(undef, @bind_cols);
In addition, execute will accept tainted @bind_values. I can't think of what a malicious user could do with a tainted bind value (in the
general case. Your application may vary.)
Thus a typical idiom would be:
$sth->execute([$this, $that], [($foo, $bar)]);
Of course, this method provides no way of passing bind attributes through to bind_param or bind_columns. If that is necessary, then you
must perform the bind_param, execute, bind_col sequence yourself.
fetch
$row_ref = $sth->fetch;
@row = $sth->fetch;
A context sensitive version of fetch(). When in scalar context, it will act as fetchrow_arrayref. In list context it will use
fetchrow_array.
fetch_hash
$row_ref = $sth->fetch_hash;
%row = $sth->fetch_hash;
A modification on fetchrow_hashref. When in scalar context, it acts just as fetchrow_hashref() does. In list context it returns the
complete hash.
fetchall
$rows_ref = $sth->fetchall;
@rows = $sth->fetchall;
A modification on fetchall_arrayref. In scalar context it acts as fetchall_arrayref. In list it returns an array of references to rows
fetched.
fetchall_hash
$rows_ref = $sth->fetchall_hash;
@rows = $sth->fetchall_hash;
A mating of fetchall_arrayref() with fetchrow_hashref(). It gets all rows from the hash, each as hash references. In scalar context it
returns a reference to an array of hash references. In list context it returns a list of hash references.
ORIGINAL AUTHOR
Michael G Schwern as part of Ima::DBI
CURRENT MAINTAINER
Tony Bowden <tony@tmtm.com>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
DBI. Ima::DBI. Class::DBI.
perl v5.10.0 2005-09-27 DBIx::ContextualFetch(3pm)