Name
DBI::execute
Synopsis
$rows_affected = $statement_handle->execute; $rows_affected = $statement_handle->execute(@bind_values);
DBI::execute
executes the SQL statement held in
the statement handle. For a non-SELECT
query, the
function returns the number of rows affected. The function returns
`-1’ if the number of rows is not known. For a
SELECT
query, some true value is returned upon
success. If arguments are provided, they are used to fill in any
placeholders in the statement (see DBI::prepare).
Example
use DBI; my $db = DBI->connect('DBI:mSQL:mydata',undef,undef); my $statement_handle = $db->prepare("SELECT * FROM mytable"); my $statement_handle2 = $db->prepare("SELECT name, date FROM myothertable WHERE name like ?"); $statement_handle->execute; # The first statement has now been performed. The values can now be accessed # through the statement handle. $statement_handle->execute("J%"); # The second statement has now been executed as the following: # SELECT name, date FROM myothertable WHERE name like 'J%'
Get MySQL and mSQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.