Subject | How I can validate a date? |
---|---|
Author | W O |
Post date | 2011-02-25T01:28:23Z |
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]
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]