From: | Brandon Metcalf <brandon(at)geronimoalloys(dot)com> |
---|---|
To: | Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> |
Cc: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: quoting values magic |
Date: | 2009-05-26 18:12:51 |
Message-ID: | Pine.LNX.4.58L.0905261312150.17654@cedar.geronimoalloys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
d == dalroi(at)solfertje(dot)student(dot)utwente(dot)nl writes:
d> On May 26, 2009, at 6:37 PM, Brandon Metcalf wrote:
d> > j> option 2: case when '$length' = '' ...
d> >
d> > j> you can use case like this:
d> >
d> > j> UPDATE foo
d> > j> SET
d> > j> pattern = '$pattern',
d> > j> shape = '$shape',
d> > j> length = case when '$length'='' then length else
d> > '$length' end,
d> > j> comment = '$comment'
d> > j> WHERE foo_id = $foo_id
d> >
d> > j> here you can substitute any value you choose for the empty string,
d> > j> 0 or NULL may (or may not) be more apropriate.
d> >
d> >
d> > The issue here is that these reduce back to my original problem. For
d> > example, if I use a CASE statement and I fall through to the ELSE,
d> > then the SQL is attempting to insert a "''" in a NUMERIC field which
d> > is not valid. That is, it's trying to do
d> No it doesn't, read that statement again ;)
Oops. Indeed, you are correct.
--
Brandon
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2009-05-26 18:18:59 | Re: Need beginning and ending date value for a particular week in the year |
Previous Message | Alban Hertroys | 2009-05-26 18:05:33 | Re: quoting values magic |