Re: last insert id
- From: ron@xxxxxxxxxxxxx (Ron Savage)
- Date: Mon, 17 Apr 2006 08:55:59 +1000
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
.
- Follow-Ups:
- Re: last insert id
- From: Daniel Kasak
- Re: last insert id
- From: Dr.Ruud
- Re: last insert id
- References:
- Re: last insert id
- From: Daniel Kasak
- Re: last insert id
- Prev by Date: Re: last insert id
- Next by Date: Re: Exception raised in DBI.pm during Scalar::Util::weaken?
- Previous by thread: Re: last insert id
- Next by thread: Re: last insert id
- Index(es):
Relevant Pages
|