Subject | RE: [firebird-support] sql update |
---|---|
Author | Alan McDonald |
Post date | 2004-02-06T21:30:21Z |
> > Hi, in a stored procedure I say something like this:I don't think this is what he wants to do..
> >
> > update aTable
> > set col1 = :inVal1, col2 = :inVal2, col3 = :inVal3
> > where col4 = '...';
> >
> > inVal1, inVal2, inVal3 and inVal4 are input parameters, and the thing is
> > that I just want to update the columns where the input parameters are
> > not null. So if inVal1 is null and the other input parameters are not, I
> > want to update col2 and col3 but not col1.
> >
> > Is there a clever way to do this, using some sort of if/case...
>
> Firebird 1.5? Cause then you might want to try something like:
>
> SET COL1 = COALESCE(:inVal1, COL1,
> COL2 = ...
>
> With regards,
>
> Martijn Tonies
It's more likely to be done in the before update trigger
if new.col1 is null then new.col1=old.col1;
etc
he wants each col to be updated if that col's param val is not null.
No?
Alan