Hello,

it seems I am too stupid to properly bind a variable. The docs did not
really help me...

What I want to do, is something like:

my $sth = $dbh->prepare("select vtr_id into ? from t_vertraege " .
                          "where vtr_nr='$vbb_ver_nr'");
my $vtr_id;
$sth->bind_param_inout(1, \$vtr_id, 10);
$sth->execute;

My first guess is that I need bind_param_inout instead of bind_param,
because I want to result returned and this can  only work with a reference.
I found bind_param_inout in Oracle.pm. There the syntax used is:

$csr->bind_param_inout(":is_odd", \$is_odd, 1);

So I tried:

  my $sth = $dbh->prepare("select vtr_id into :vtr_id from t_vertraege " .
                          "where vtr_nr='$vbb_ver_nr'");
  my $vtr_id;
  $sth->bind_param_inout(":vtr_id", \$vtr_id, 10);
  $sth->execute;

which produces:

DBD::Oracle::st bind_param_inout failed: ORA-01036: illegal variable
name/number (DBD ERROR: OCIBindByName) at ./schnitt.pl line 455, <INFILE>
chunk 58.

Oracle.pm says:

       # I could have used positional placeholders (e.g. :1, :2, etc.) or
       # ODBC style placeholders (e.g. ?), but I prefer Oracle's named
       # placeholders (but few DBI drivers support them so they're not
portable)

DBI.pm says:

       $rc = $sth->bind_param_inout($p_num, \$bind_value, $max_len)

2nd try:

  my $sth = $dbh->prepare("select vtr_id into ? from t_vertraege " .
                          "where vtr_nr='$vbb_ver_nr'");
  my $vtr_id;
  $sth->bind_param_inout(1, \$vtr_id, 10);
  $sth->execute;

which produces again:

DBD::Oracle::st bind_param_inout failed: ORA-01036: illegal variable
name/number (DBD ERROR: OCIBindByName) at ./schnitt.pl line 455, <INFILE>
chunk 58.

Any comments, help, flames... are welcome,
Peter

PS: using DBI 1.15, DBD Oracle 1.06 and perl 5. 005_03

Reply via email to