MySQL Forums
Forum List  »  Perl

Procedure wont work ?
Posted by: Tim Vantag
Date: February 05, 2007 06:50AM

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 ?

Options: ReplyQuote


Subject
Written By
Posted
Procedure wont work ?
February 05, 2007 06:50AM
March 18, 2007 09:55PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.