Re: how to set a DEFAULT value !!
- From: greg@xxxxxxxxxxxx (Greg Sabino Mullane)
- Date: Mon, 24 Apr 2006 15:27:02 -0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I would like to do in SQL
" INSERT table VALUES (DEFAULT, NOW()); "
...
is there any simple way I can write like this?
I'm not exactly sure how DBI::Class does things, but currently
in plain old DBI your only real option is to create a separate statement
handle like this:
my %sth;
$sth{nodefault} = $dbh->prepare("INSERT INTO mytable(foo,bar) VALUES (?, ?)");
$sth{nodefault}->execute(11,12);
$sth{default} = $dbh->prepare("INSERT INTO mytable(foo,bar) VALUES (DEFAULT, ?)");
$sth{default}->execute(12);
In recent versions of DBD::Pg, you can also pass in a special variable to the
execute method which allows using only one statement handle:
$sth{nodefault}->execute($DBDPG_DEFAULT, 12);
I've proposed adding something simlilar to DBI itself, but I don't recall getting
any feedback on it. Presumably once in place DBIx::Class will someday support it.
- --
Greg Sabino Mullane greg@xxxxxxxxxxxx
PGP Key: 0x14964AC8 200604241124
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iD8DBQFETO4zvJuQZxSWSsgRApL3AKDLdmt0B+G0d5eziZYMnEW3LyULsQCgzj5n
gJWNshh94iV5vrdHDLnuA7k=
=DgPG
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: how to set a DEFAULT value !!
- From: David Nicol
- Re: how to set a DEFAULT value !!
- References:
- how to set a DEFAULT value !!
- From: T. H. Lin
- how to set a DEFAULT value !!
- Prev by Date: RE: last insert id
- Next by Date: Re: last insert id
- Previous by thread: how to set a DEFAULT value !!
- Next by thread: Re: how to set a DEFAULT value !!
- Index(es):
Relevant Pages
|