Re: last insert id



On Sun, 16 Apr 2006 22:15:22 +1000, Daniel Kasak wrote:

Hi Daniel

DBI: V 1.47
DBD::mysql: V 3.002

sub last_insert_id
{
my($self, $table_name) = @_;

my($id);

if ($self -> db_vendor() =~ /(?:mysql|Pg)/)
{
$id = $self -> dbh() -> last_insert_id(undef, undef, $table_name, undef);
}
else # Oracle.
{
my($sth) = $self -> dbh() -> prepare("select ${table_name}_id_seq.currval from
dual");

$sth -> execute();

$id = ${$sth -> fetch()}[0];

$sth -> finish();
}

return $id;

} # End of last_insert_id.

--
Cheers
Ron Savage, ron@xxxxxxxxxxxxx on 17/04/2006
http://savage.net.au/index.html
Let the record show: Microsoft is not an Australian company


.



Relevant Pages

  • Re: Rows returned are out of sync with the request.
    ... sub getstatus_by_certno { ... undef $sth if; ... # reset alarm JIC ... return %tbl; ...
    (perl.dbi.users)
  • Re: Forms refresh
    ... because it is sth like form.ShowDialogand unless the messageBox is closed ... But sth in both cases is not so good....It is that your dialog ... Put the repaint functions in a Sub() and call the sub from a Timer_Tick ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Rows returned are out of sync with the request.
    ... sub getstatus_by_certno { ... Can $sth ever be already defined here? ... # reset alarm JIC ... return %tbl; ...
    (perl.dbi.users)
  • RE: If cell value is greater than another cell value, clear conten
    ... If you want to do it with 'selection' then select the range and use this ... Sub sth() ... End Sub ... and clears out any dates which are greater than the value in cell G4. ...
    (microsoft.public.excel.programming)
  • Re: last insert id
    ... Ron Savage wrote: ... DBI: V 1.47 ... else # Oracle. ... $sth -> execute; ...
    (perl.dbi.users)