Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
Subject: mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Subject: Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
Subject: MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Subject: Re: Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Subject: Problem when calling stored procedure

Subject: Problem when calling stored procedure

2007-11-04       - By Pierre Hainard

 Back
Hello
I try to read a stored procedure p1 from a table listproc in database test
_texte and use it after giving a value to her parameters in an other database.

#/usr/bin/perl

use strict;
use warnings;
use DBI;

my @(protected);
my $user = 'papa';my $password = 'pa3418';
my $para1;my $para2;

my $dbh_1 = DBI->connect ("dbi:mysql:test_texte",$user,$password,
{RaiseError => 1, PrintError => 1})
or die "can't connect ($DBI::errstr)\n";

my $sth_1 = $dbh_1->prepare("SELECT Liste FROM listeproc");
$sth_1->execute;
my $cont = 0;
while ($linproc[$cont] = $sth_1->fetchrow_array ) {
$cont++;
     }
print "linproc[0] is : $linproc[0]";
$dbh_1->disconnect;

my $dbh = DBI->connect ("dbi:mysql:test",$user,$password,
{RaiseError => 1, PrintError => 1})
or die "can't connect ($DBI::errstr)\n";


#
# Calling the procedure
$para1 = 10;$para2 = 12;
my $procedure = "CALL p1($para1,$para2)";


#this one does  work
my $sth = $dbh->prepare($procedure);
#this one does not work  why ??
#my $sth = $dbh->prepare({$linproc[0]});
$sth->execute();

my $more_results;
my $count = 0;
do {
   $count++;
   print "\ndonnees $count\n";
   my $names = $sth->{NAME};
   print_line($names);
   print_line([map {'-' x length $_} @$names]);
   my $rows = $sth->fetchall_arrayref();
   print_line ($_) for @$rows;
} while ( $more_results = $sth->more_results);

$dbh->disconnect;

sub print_line {
   my ($line) = @(protected);
   print q{  }, join(q{ }, map {sprintf '%-12s', $_} @$line),"\n";
}

sleep(20);

Meilleures salutations


Pierre Hainard
Chalet 15
CH-2300 La Chaux de Fonds
p.hainard@(protected)