in reply to DBI help please

I've never seen placeholders used for data output, and I don't know if it's supported. I'd try:

my $sth = $dbh->prepare('insert ... returning term_id'); $sth->execute($rows->[$num][1], state($rows->[$num][2])); my ($value) = $sth->fetchrow; $sth->finish;

Replies are listed 'Best First'.
Re^2: DBI help please
by TendulkarIsGod (Acolyte) on Dec 07, 2010 at 20:56 UTC

    didn't work.. , oracle barfed an error message all over my nice clean screen

    my changed code:

    $stm = "insert into glossary (term_id, definition, state) values (seq_document_id.NEXTVAL,?,?) returning term_id"; $sth = $dbh->prepare($stm); $sth->execute($rows->[$num][1], state($rows->[$num][2])); my ($value) = $sth->fetchrow($sth);

    it croaked with

    DBD::Oracle::st execute failed: ORA-00925: missing INTO keyword (DBD ERROR: error possibly near <*> indicator at char 108 in 'insert into glossary (term_id, definition, state) values (seq_document_id.NEXTVAL,:p1,:p2) returning term_id<*>')

      Since I never used Oracle, I don't really know how to do it. If nobody else has a better idea, maybe take a look at how DBIx::Class does it - it sure needs to obtain the primary key for an insert.