#!/usr/bin/perl # # PROCEDURE `TEST_COUNT_PLUS` # # CREATE DEFINER=`root`@`localhost` PROCEDURE `TEST_COUNT_PLUS`(INOUT +NUMBER1 INTEGER) # BEGIN # DECLARE NUMBER2 INTEGER # DEFAULT (SELECT COUNT(*) FROM PLAYERS); # SET NUMBER1 = NUMBER2 + NUMBER1; # END$$ use strict; use DBI; my @hit_count; my $dbh = DBI->connect('dbi:mysql:tennis','BOOKSQL','BOOKSQLPW') or di +e "Connection Error: $DBI::errstr\n"; $dbh->do('set @hit_count=10'); # change " to ', disable interpreter. my $sql = 'call TEST_COUNT_PLUS(@hit_count)'; my $sth = $dbh->prepare($sql); $sth->execute || die $DBI::errstr; $sth->finish; # Now get the output variable my @result = $dbh->selectrow_array('SELECT @hit_count') || die $DBI::e +rrstr; print "result=", $result[0], "\n"; $dbh->disconnect;
In reply to Re^5: Calling MySQL stored procedures with in and out parameters
by morning_leaf
in thread Calling MySQL stored procedures with in and out parameters
by Benedict White
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |