And it worked (this was for Oracle, thus, the 'FROM dual'). This is, of course, just an example SQL statement, but may also be most useful for others, like INSERT statements...my @cols = qw(foo bar); my $sql = <<SQL; SELECT :foo, :bar FROM dual SQL my $sth = $dbh->prepare($sql); my %hsh; for (@cols) { $sth->bind_param_inout( ":$_" => \$hsh{$_}, 0 ); } # Set constants... $hsh{foo} = 'abc'; # Set changing values $hsh{bar} = 123; $sth->execute(); while (my @arr = $sth->fetchrow_array) { print "@arr\n"; } $hsh{bar} = 456; $sth->execute(); while (my @arr = $sth->fetchrow_array) { print "@arr\n"; } $dbh->disconnect();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI bind_param_inout trick
by mje (Curate) on Sep 03, 2012 at 16:11 UTC | |
by mje (Curate) on Sep 03, 2012 at 16:58 UTC | |
by mje (Curate) on Sep 05, 2012 at 09:22 UTC | |
by runrig (Abbot) on Sep 05, 2012 at 16:52 UTC | |
by mje (Curate) on Sep 06, 2012 at 08:03 UTC | |
|
Re: DBI bind_param_inout trick
by locked_user sundialsvc4 (Abbot) on Aug 22, 2012 at 22:21 UTC | |
by runrig (Abbot) on Aug 22, 2012 at 22:57 UTC | |
by tye (Sage) on Aug 23, 2012 at 00:58 UTC |