Subject NULL parameters in Stored Procedures failing updates
Author Luis Madaleno
Hi,

I have this SP:
CREATE PROCEDURE SAVE_CC (id BIGINT)
RETURNS (
result SMALLINT)
AS
DECLARE VARIABLE ...
...
begin
IF (EXISTS(SELECT 1 FROM LIQUIDACOES_FOR WHERE ID=:ID)) THEN
BEGIN
FOR
SELECT OBRA_ID, LIQUIDADO, REF_DOCUMENTO
FROM LIQUIDACOES_FOR_DETALHE
WHERE PARENT_ID=:ID
INTO :OBRA_ID, :LIQUIDADO, :REF_DOCUMENTO
DO
BEGIN
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?

Regards,

Luis Madaleno