Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

With DBI/DBD-Oracle I have the following code to insert a row in a table and return the PROGID into 'id':
my $insql = " INSERT INTO PROGTBL (column names...) VALUES ( ?, ?, ?) RETURNING PROGID INTO :id "; my $sth = $self->dbh->prepare($insql) or die "Can't prepair statement: + $self->DBI::errstr"; $sth->bind_param_inout(":id", \my $new_id, 99); $sth->execute( $foo, $bar, $baz ) or die "Can't execute statement: $se +lf->DBI::errstr";

I'm geting th error

DBI error Can't mix placeholder styles (:foo/?)

I don't understand how to fix it. Any ideas?

Replies are listed 'Best First'.
Re: DBI error Can't mix placeholder styles (:foo/?)
by mje (Curate) on Jun 21, 2011 at 09:21 UTC

    Change the ":id" in your SQL to a ? and change the bind_param_inout calls first argument to 4. You cannot mix placeholder styles.

      I get a different error after that change:
      DBD::Oracle::st execute failed: called with 3 bind variables when 4 ar +e needed
      my $insql = " INSERT INTO PROGTBL (cola, colb, colc ) VALUES ( ?, ?, ?) RETURNING PROGID INTO ? "; my $sth = $self->dbh->prepare($insql) or die "Can't prepair statem +ent: $self->DBI::errstr"; $sth->bind_param_inout(4, \my $new_id, 99); $sth->execute( $foo, $bar, $baz)

        Yes, sorry. You need to bind the input parameters by calling bind_param().