Subject Re: [firebird-support] CASE and SQL
Author Ivan Prenosil
> When doing a SELECT I can use CASE statement.
> Something like:
>
> Select
> Field1,
> Case when (SomeCondition) then
> FIeld2
> else
> Field3
> end
> from MyTable
>
>
> Can I do something alike when doing and update ?
> I.E.
>
> Update MyTable set
> FIeld1 = SomeVAlue,
> Case when (SomeCOndition) then
> Field2 = 1
> else
> Field3 = 2
> end

----------

Either:

Update MyTable set

FIeld1 = SomeVAlue,

Field2 = Case when (SomeCondition) then
1
else
Field2
end,

Field3 = Case when (SomeCondition) then
Field3
else
2
end;

----------

Or:

Update MyTable set
FIeld1 = SomeVAlue, Field2 = 1
Where SomeCondition;

Update MyTable set
FIeld1 = SomeVAlue, Field3 = 2
Where SomeConditionIsNotTrue;

----------
Ivan