or download this
$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);