Subject Re: [firebird-support] How I can validate a date?
Author Anderson Farias
Hi,

IF (FECING IS NULL OR FECING < '01.01.2011') THEN
-- exception ...


Regards,
Anderson

--- Em qui, 24/2/11, W O <sistemas2000profesional@...> escreveu:

De: W O <sistemas2000profesional@...>
Assunto: [firebird-support] How I can validate a date?
Para: firebird-support@yahoogroups.com
Data: Quinta-feira, 24 de Fevereiro de 2011, 22:28







 









Hello everybody



How I can validate a date in a Stored Procedure?



How I can raise an exception if an input parameter of type date is empty or

null?



Something like the next code doesn't work:



CREATE DOMAIN D_DATE1 AS

DATE

NOT NULL

CHECK (

VALUE >= '01.01.2011'

);



SET TERM ^ ;



CREATE PROCEDURE SAVEDATE(

FECING TYPE OF D_DATE1)

RETURNS(

CERRORMESSAGE VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1)

AS

BEGIN



cErrorMessage = '';



IF (EXTRACT(YEAR FROM :FECING) = 0) THEN EXCEPTION EX_INVALIDDATE;



WHEN EXCEPTION EX_INVALIDDATE DO

cErrorMessage = 'I need to know the date';



WHEN ANY DO

cErrorMessage = 'ERROR ' || SQLCODE || ' ' || GDSCODE;



END^



SET TERM ; ^



I need to trap when the date is empty or null.



Thanks in advance.



Walter.



[Non-text portions of this message have been removed]

























[Non-text portions of this message have been removed]