On Tue, Feb 24, 2004 at 09:33:31PM -0500, Rudy Lippan wrote: > > This is something that I have wanted to do every now and again, but I > don't know how to do this cleanly in DBI. Is there an official DBI way > to bind a column as 'DEFAULT'?
No. Not just no official way, but no way at all (if you're using server-side placeholders). Same issue as trying to bind a function like SYSDATE. Tim. > For example, let us say that I wanted to do this insert: > > my $sth = $dbh->prepare(q{ > INSERT INTO foo (col0, col1, col2, col3) > VALUES (DEFAULT, :col1, :col2, :col3) > }); > > if ('col1_is_default') { > # How do I do this bind? > # hack that should work with DBD::mysql & DBD::Pg > $sth->bind_param(":col1", 'DEFAULT' SQL_INTEGER); > > # Could probably add an attribute {(pg|mysql)_default=>1}? > } else { > $sth->bind_param(":col1" Not default); > } > > for (my $x;;$x++) { > $sth->bind_param("col2", "foo $_"); > $sth->bind_param("col3", "bar $_"); > $sth->execute; > } > > > Rudy >