On Tue, Sep 13, 2005 at 05:44:23PM +0100, Tim Bunce wrote: > On Tue, Sep 13, 2005 at 03:31:35PM +0200, Paskamp, Marco wrote: > > Hi, > > I'm thinking about the support of default values as parameter bind > > for a prepared statement. Before I implement a special DBD::MaxDB > > solution I would like to ask if there is a standardized way to do > > this in DBI. For understanding, you can set the NULL value when > > you bind undef but how can you set the DEFAULT value for a > > parameter? > > You mean DEFAULT as in > > INSERT INTO foo VALUES (1, DEFAULT, "bar"); > > where the _SQL_keyword_ DEFAULT triggers the use of whatever value was > declared as the DEFAULT value in the table definition?
That's one I'd like :) > > If DBI does not support default values as parameter are there any other > > driver that support this. If yes, how is it solved? > > Well here's one way that might work: > > INSERT INTO foo VALUES (?, IFNULL(?,DEFAULT), "bar"); > > (substitute something else for IFNULL isn't that's not quite right) > but I'm not sure if that's valid and/or viable. <rant> Please pardon my putting it so bluntly, but this is Bad and Wrong(TM) because it's set up to alter user input silently. While such behavior may be tolerable in some hemipygian shareware tinkertoy "DBMS" from Sweden whose users I will not embarrass by naming its brand name, it is not even remotely OK in general. </rant> Anyhow, I'm working with the PostgreSQL jdbc developers on a similar method, and hope to get the message over to Sun. Is there some way we could make DEFAULT a special thing the way undef <-> NULL is? Cheers, D -- David Fetter [EMAIL PROTECTED] http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
