selectrow_array()
$dbh->selectrow_array($sql_statement[, \%attri, @values])
This function returns one row from the results of an SQL
statement in the form of an array, where each column returned is
represented by an element of the array, in order. This method combines
prepare(),
execute(), and
fetchrow_array(). No statement handle is
created, so finish() is unnecessary. An
optional second argument can specify any of the attributes allowed for
a statement handle. If placeholders are used in the SQL statement,
their values must be given as an array for the third argument. Here is
an example:
...
my $sql_stmnt = "SELECT title, author
FROM books WHERE book_id = ?";
my ($title, $author) = $dbh->selectrow_array($sql_stmnt, undef, '1234');
print "$title by $author \n";No attributes are given for the SQL statement in this example,
so undef is used for the second argument. The third
argument provides the book_id value for the
placeholder in the SQL statement. Notice that this
select_ type of database handle method does not
require the use of a control statement to parse the data because it
retrieves only one row of data. The prepare()
method isn’t called to create a statement handle if the SQL statement
is given (as it is here), which means
finish() is unnecessary. However, a statement
handle could be given instead.