Hello again pryt,
I hope you still follow our thread. I found some time and decide to look into it a bit more. Regarding the part you said # thanos1983's links suggested a two-step process: can be done in one step also to minimize the resources. You can use the do method. In your case it can be used without the prepare execute step.
From the documentation:
This method is typically most useful for non-SELECT statements that ei +ther cannot be prepared in advance (due to a limitation of the driver +) or do not need to be executed repeatedly. It should not be used for + SELECT statements because it does not return a statement handle (so +you can't fetch any data).
Having said that, here is a sample that replicates your test, based on your final post:
#!/usr/bin/perl use strict; use warnings; use Test::More; use DBI qw/:sql_types/; my $dsn = 'DBI:mysql:database=DB'; my $dbh = DBI->connect($dsn, 'user', 'psw', {RaiseError => 1}); my $sth = $dbh->prepare('SELECT "Hello World"'); $sth->execute(); printf "SELECT rows = %d\n", scalar $sth->rows; printf "\t(@$_)\n" for $sth->fetchrow_arrayref; my $rows = $dbh->do('CALL DebugMe(@dmvar)') or die $dbh->errstr; my ($v) = $dbh->selectrow_array('SELECT @dmvar'); is( $dbh->errstr , undef , 'SELECT(@dmvar) without error' ); is( $v , 'HELLO' , 'DebugMe(@dmvar); SELECT @dmvar' ); done_testing(); $sth->finish; __END__ $ perl mysql.pl SELECT rows = 1 (Hello World) ok 1 - SELECT(@dmvar) without error ok 2 - DebugMe(@dmvar); SELECT @dmvar 1..2
The idea came from the MySQL forums HOW TO RETRIEVE AN "OUT" PARAMETER OF MYSQL STORED PROCEDURE IN PERL. I remembered the user mentioned that is working, worth it to give it a try.
Relevant question Multiple data sets in MySQL stored procedures,in case of future reference(s).
Hope this helps, BR.
In reply to Re: How to access MySQL stored procedures OUT parameter(s)
by thanos1983
in thread How to access MySQL stored procedures OUT parameter(s)
by pryrt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |