TendulkarIsGod has asked for the wisdom of the Perl Monks concerning the following question:
monks, please advise
$stm = "insert into glossary (term_id, definition, state) values (seq_document_id.NEXTVAL,?,?) returning term_id into ?"; $sth = $dbh->prepare($stm); $sth->execute($rows->[$num][1], state($rows->[$num][2]), $value); die unless ($value);
the statement inserts into the db, but returns a null value to $value. From querying the db, i know that term_id is being successfully updated with seq_doc_id.NEXTVAL, but for some reason the 'returning into' part does not want to behave, and keeps giving me null values. what am i doing wrong?
UPDATE: Thanks for the advice, folks. Found out the resolution. The best way to do it was to use
$sth->bind_param(1,$variable) $sth->bind_param(2,$variable) $sth->bind_param_inout(3,\$value,max_length) $sth->execute();
thanks to ruzam for clarifying that execute() is a one-way communication channel, that was the key for me to find the solution. much appreciated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI help please
by ruzam (Curate) on Dec 07, 2010 at 21:28 UTC | |
|
Re: DBI help please
by erix (Prior) on Dec 07, 2010 at 19:12 UTC | |
by TendulkarIsGod (Acolyte) on Dec 07, 2010 at 19:29 UTC | |
|
Re: DBI help please
by moritz (Cardinal) on Dec 07, 2010 at 19:44 UTC | |
by TendulkarIsGod (Acolyte) on Dec 07, 2010 at 20:56 UTC | |
by moritz (Cardinal) on Dec 07, 2010 at 21:39 UTC |