Subject RE: [firebird-support] NULL parameters in Stored Procedures failing updates
Author Nick
BEGIN
IF OBRA_ID IS NULL
THEN
UPDATE CONTAS_CORRENTES_FOR SET
TOTAL_LIQUIDADO=TOTAL_LIQUIDADO+:LIQUIDADO
WHERE OBRA_ID is null AND DOCUMENTO=:REF_DOCUMENTO;
ELSE
UPDATE CONTAS_CORRENTES_FOR SET
TOTAL_LIQUIDADO=TOTAL_LIQUIDADO+:LIQUIDADO
WHERE OBRA_ID=:OBRA_ID AND DOCUMENTO=:REF_DOCUMENTO;
END

--
Nick
-----We Solve your Computer Problems---
UNIX, C, Panther, Ingres, Interbase, Firebird - Available Shortly

> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com] On Behalf Of Luis Madaleno
> Sent: 27 June 2006 18:07
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] NULL parameters in Stored
> Procedures failing updates
>
>
> 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
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> Check out the new improvements in Yahoo! Groups email.
> http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/67folB/TM
> --------------------------------------------------------------
> ------~->
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>