use strict; use warnings; use DBD::DB2; use DBD::DB2::Constants; use Test::More; plan q/no_plan/; # I'm the man with no plan .. sub DBSETUP_PARAMS { return ('DBI:DB2:viper', 'db2inst1', '*****'); } # Call function with unbound value sub call_func_nobind { my $cardno = shift; my $rv = undef; my $dbh = DBI->connect(DBSETUP_PARAMS()); die(q{Connect failed!}) if (!defined($dbh)); my $sth = $dbh->prepare( qq{SELECT DB2INST1.FUNC_JUST_RETURN_IT($cardno) FROM SYSIBM.SYSDUMMY1}); die(q{Prepare failed!}) if (!defined($sth)); $sth->execute() or die (q{execute failed}); die(q{Execute failed!}) if (!defined($sth)); my $row = $sth->fetchrow_arrayref(); ($row) ? $row->[0] : undef; } # Failing attempt to call function with bound value sub call_func_bind { my $cardno = shift; my $rv = undef; my $dbh = DBI->connect(DBSETUP_PARAMS()); die(q{Connect failed!}) if (!defined($dbh)); my $sth = $dbh->prepare(qq{SELECT DB2INST1.FUNC_JUST_RETURN_IT(?) FROM SYSIBM.SYSDUMMY1}); die(q{Prepare failed!}) if (!defined($sth)); $sth->bind_param(1, $cardno); die(q{bind_param failed!}) if (!defined($sth)); $sth->execute() or die (q{execute failed}); die(q{Execute failed!}) if (!defined($sth)); my $row = $sth->fetchrow_arrayref(); ($row) ? $row->[0] : undef; } # ------ main ------ cmp_ok(call_func_nobind(q{123456}), q{==}, 123456, q{Expect 123456 returned}); cmp_ok(call_func_bind(q{123456}), q{==}, 123456, q{Expect 123456 returned}); 1; __END__