my %dispatch = ( # Key = name of proc # Value = array of arguments to pass "PAR_REPORTS_POS.SUN_PRC_AT_I_POSM1D007" => [ \$retcode, \$retmsg ], "PAR_REPORTS_POS.SUN_PRC_AT_I_POSM1W001" => [ \$retcode, \$retmsg, \$finRepId, \$showPendingPolicies ], # and so on ); # Later... my $args = $dispatch{$procName}; my $procedure = "BEGIN $procName( " . join(',', (('?') x @$args)) # that makes a comma-separated list of '?'s, # the same number as there are elements in $args . "); END;"; my $function = $dbh->prepare($procedure); my $argc = 1; for my $arg (@$args) { $function->bind_param($argc++, $arg, SQL_VARCHAR); } $function->execute;