Subject Re: [firebird-support] NULL parameters in Stored Procedures failing updates
Author Ann W. Harrison
Luis Madaleno wrote:
> ...
> UPDATE CONTAS_CORRENTES_FOR SET
> TOTAL_LIQUIDADO=TOTAL_LIQUIDADO+:LIQUIDADO
> WHERE OBRA_ID=:OBRA_ID AND DOCUMENTO=:REF_DOCUMENTO;
> /* the problem is here. if :OBRA_ID is null, this UPDATE fails */
> END
> END
> end^
>
> is there any way to force this UPDATE to work when one parameter is null?
>

WHERE (OBRA_ID=:OBRA_ID or :obra_id is null)
AND (DOCUMENTO=:REF_DOCUMENTO or :ref_documento is null)
AND NOT (:orbra_id is null and :ref_documento is null);

The last bit keeps two null values from changing the whole table.

Regards,


Ann