in reply to DBI bind params & column defaults

Isn't that the same question that I asked in How to get a placeholder to keep the current column value? and was answered by Jenda?

Liz

Replies are listed 'Best First'.
Re: Re: DBI bind params & column defaults
by shemp (Deacon) on Oct 27, 2003 at 18:26 UTC
    Yes in fact it seems to be effectively the same. I hadnt found that thread in my poking around here. :(

    In regard to Jenda's solution, it sounds specific to UPDATE queries. Any idea what'll happen on an insert query? I suppose i could just try it out myself!

    Thanks much!

      You could use COALESCE just as well on INSERT. Something like:
      INSERT INTO table (id,type) VALUES ( id, COALESCE(?,defaulttypevalue) )
      Well, in general if a field is given the NULL value (which will be inserted if the given value for a placeholder is undef), then the database decides what to do with it. Usually it will just be marked as NULL in the database (as in: not having any value). Sometimes you can specify a default value when you create the table. Sometimes something special happens (e.g. with a TIMESTAMP field in MySQL).

      Liz

Re: Re: DBI bind params & column defaults
by cchampion (Curate) on Oct 27, 2003 at 19:23 UTC
    and was answered by Jenda?

    I was under the impression that many wise monks answered your question. Jenda's solution is just one of the many you got.

      The answers of the wise monks, apart from Jenda's answer which introduced COALESCE() to me, all involved creating the query on the fly, over and over again. This is something that I have been doing since basically 1995, so that didn't bring much news to me.

      In my opinion, Jenda's answer was the only one that addressed the fixedness of the statement handle for the update. And therefore was considered an avenue for me to go in. And also in this thread, the only new answer for shemp as far as I can see.

      MySQL 4.1 seems to support prepared statements on the server side. Too bad DBD::mysql doesn't support that yet. Any takers? ;-)

      Liz