Date format dd/mm/yyyy and ddmmyy
From: Pierre Bar <_pierre.bar_at_tractebel.be_>
Date: 1997/04/24
Message-ID: <01bc5079$5cb10060$b103018e_at_pc4496>#1/1
END IF;
END;
You place a call to this procedure in the WHEN-VALIDATE-ITEM trigger associated with the field :
Siecle(:<block>.<field>);
To detect another format than dd/mm/yyyy, you can write a function like this :
Function Format RETURN Date is
Code_erreur NUMBER := ERROR_CODE;
Type_erreur VARCHAR2(3) := ERROR_TYPE; Texte_erreur VARCHAR2(80) := ERROR_TEXT; Champ VARCHAR2(20);
formate date;
annee number;
BEGIN
Champ := NAME_IN(NAME_IN('system.trigger_item')); IF Code_erreur = 40209
AND INSTR(UPPER(texte_erreur),'DD/MM/YY') > 0 THEN Champ := NAME_IN(NAME_IN('system.trigger_item')); IF INSTR(champ, '/') = 0 THEN
annee := TO_NUMBER(SUBSTR(champ, 5)); if annee < 50 then
annee := annee + 2000;
elsif annee < 100 then
annee := annee + 1900;
end if;
formate := TO_DATE(SUBSTR(Champ, 1,2) || '/' || SUBSTR(champ,3,2) || '/' || TO_CHAR(annee),'dd/mm/yyyy');
Date: 1997/04/24
Message-ID: <01bc5079$5cb10060$b103018e_at_pc4496>#1/1
It's possible to have a format such "dd/mm/yyyy" and type something like
010197 using the following technique.
You must define a procedure :
PROCEDURE Siecle (jour IN OUT date) IS
Annee NUMBER;
BEGIN
Annee := TO_NUMBER(TO_CHAR(jour,'YYYY'));
IF Annee < 100 THEN
IF Annee < 50 THEN Jour := ADD_MONTHS(jour, 2000*12); ELSE Jour := ADD_MONTHS(jour, 1900*12); END IF;
END IF;
END;
You place a call to this procedure in the WHEN-VALIDATE-ITEM trigger associated with the field :
Siecle(:<block>.<field>);
To detect another format than dd/mm/yyyy, you can write a function like this :
Function Format RETURN Date is
Code_erreur NUMBER := ERROR_CODE;
Type_erreur VARCHAR2(3) := ERROR_TYPE; Texte_erreur VARCHAR2(80) := ERROR_TEXT; Champ VARCHAR2(20);
formate date;
annee number;
BEGIN
Champ := NAME_IN(NAME_IN('system.trigger_item')); IF Code_erreur = 40209
AND INSTR(UPPER(texte_erreur),'DD/MM/YY') > 0 THEN Champ := NAME_IN(NAME_IN('system.trigger_item')); IF INSTR(champ, '/') = 0 THEN
annee := TO_NUMBER(SUBSTR(champ, 5)); if annee < 50 then
annee := annee + 2000;
elsif annee < 100 then
annee := annee + 1900;
end if;
formate := TO_DATE(SUBSTR(Champ, 1,2) || '/' || SUBSTR(champ,3,2) || '/' || TO_CHAR(annee),'dd/mm/yyyy');
RETURN Formate;
ELSE
RAISE VALUE_ERROR;
END IF;
ELSE
RAISE VALUE_ERROR;
END IF;
EXCEPTION
WHEN VALUE_ERROR THEN
Message (Type_erreur||'-'||TO_CHAR(code_erreur)||': '||texte_erreur);
RAISE FORM_TRIGGER_FAILURE;
END Format;
END;
and you associated to your field a trigger ON-ERROR like this :
:<block>.<field> := format;
Received on Thu Apr 24 1997 - 00:00:00 CEST