Subject | Re: Using one prepared statement for updating different fields. |
---|---|
Author | rogervellacott |
Post date | 2007-05-21T15:27:18Z |
You can write the update query in the following form:
UPDATE MY_TABLE SET
MYFIELD1 = COALESCE(:MYPARAM1,MYFIELD1),
MYFIELD2 = COALESCE(:MYPARAM2,MYFIELD2)
WHERE ...etc
Make sure that the parameter values are NULL for those fields you do
not want to update.
Roger Vellacott
Passfield Data Systems Ltd
--- In firebird-support@yahoogroups.com, "ariel.sakin" <asakin@...>
wrote:
UPDATE MY_TABLE SET
MYFIELD1 = COALESCE(:MYPARAM1,MYFIELD1),
MYFIELD2 = COALESCE(:MYPARAM2,MYFIELD2)
WHERE ...etc
Make sure that the parameter values are NULL for those fields you do
not want to update.
Roger Vellacott
Passfield Data Systems Ltd
--- In firebird-support@yahoogroups.com, "ariel.sakin" <asakin@...>
wrote:
>table
> Hello,
> I have the following prepared statement:
> UPDATE TABLE requests SET f1=?, f2=?, f3=?
>
> Where f1 f2 and f3 are columns that may contain large string values
> (some of them may be BLOBs). In reality I have 20+ columns.
>
> I am looking for a way of using that statement for updating my
> without having to provide it with all the values all the time. forforced
> example, if I need to update only f1 and f3 I don't want to be
> to pass the value for f2 that do not need to be changed.overhead
> Writing a different statement for every column is not a good option
> since sometimes I need to update 15 out of 20 fields and the
> of running 15 queries is too large.
>
> Is there a way to do it?
>
> Thanks,
> Ariel Sakin
>