Hi.
I started to learn about the procedures.
I tested procedures in mysql promt and it worked well:
Here I is the procedure:
CREATE PROCEDURE born_in_year (year_of_birth INT)
SELECT first_name, last_name, birth, death
FROM president
WHERE YEAR(birth) = year_of_birth;
Then I tested it in mysql prompt:
CALL born_in_year(1908);
Results:
+------------+-----------+--------------------------+-------------
| first_name | last_name | birth | death |
+------------+-----------+--------------------------+-------------
| Lyndon B. | Johnson | 1908-08-27 | 1973-01-22 |
+------------+-----------+--------------------------+-------------
But.
When I tried to make perl program where I use procedure I get error:
DBD::mysql::st execute failed: PROCEDURE testdb.born_in_year can't return a result set in the given context at ./test.pl line 32.
Can't execute statement: PROCEDURE testdb.born_in_year can't return a result set in the given context at ./test.pl line 32.
Here is the perl program:
my $sql ="CALL born_in_year(1908)";
$sth = $db_conn->prepare($sql) or die "Can't prepare statement: $DBI::errstr";
$sth->execute() or die "Can't execute statement: $DBI::errstr";
my @results = $sth->fetchrow_array;
$sth->finish();
could you please help me and tell what's wrong ?
What should I do ?