in reply to Re: Calling MySQL stored procedures with in and out parameters
in thread Calling MySQL stored procedures with in and out parameters
How can I input the INOUT parameter value to the procedure?#!/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 DBI; my $dbh = DBI->connect('dbi:mysql:tennis','BOOKSQL','BOOKSQLPW') or di +e "Connection Error: $DBI::errstr\n"; $dbh->do("set @hit_count=10"); # error, don't work!!! 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 @result = $dbh->selectrow_array('SELECT @hit_count') || die $DBI::errs +tr; print "result=", $result[0], "\n"; $dbh->disconnect;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Calling MySQL stored procedures with in and out parameters
by hippo (Archbishop) on Apr 06, 2015 at 08:41 UTC | |
by morning_leaf (Initiate) on Apr 06, 2015 at 15:25 UTC | |
by morning_leaf (Initiate) on Apr 06, 2015 at 15:39 UTC |