Birthday check [message #10125] |
Tue, 06 January 2004 01:29 |
Furda
Messages: 1 Registered: January 2004
|
Junior Member |
|
|
I want to check if the birthday is older then sysdate
I've done this like this :
constraint M_GEBDAT_CHECK
check(gebdatum > sysdate)
Everytime i run mu script Iracle complains that sysdate is not properly used .... :(
It may also be more complex (+ 18 or +21)
But like this its already good)
Already Thnx In avant ;)
Bye bye
|
|
|
|
|
|
Re: Birthday check [message #10129 is a reply to message #10128] |
Tue, 06 January 2004 01:59 |
Furdah
Messages: 3 Registered: January 2004
|
Junior Member |
|
|
Euh no , but we are not working with developer , we are designing the database in oracle and the further development are we going to do in VB.NET ,
BUT we have to catch everything in the database , So can we use triggers in oracle ???
Thx
Grtzzz
|
|
|
Re: Birthday check [message #10136 is a reply to message #10129] |
Tue, 06 January 2004 03:35 |
|
Barbara Boehmer
Messages: 9090 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
You don't need the Developer Suite. You can create a database trigger from SQL*Plus or a .sql script. Here is an example:
scott@ORA92> CREATE TABLE your_table_name
2 (gebdatum DATE)
3 /
Table created.
scott@ORA92> CREATE OR REPLACE TRIGGER m_gebdat_check
2 BEFORE INSERT ON your_table_name
3 FOR EACH ROW
4 BEGIN
5 IF :NEW.gebdatum <= SYSDATE
6 THEN
7 RAISE_APPLICATION_ERROR (-20001, 'Birthday must be greater than today');
8 END IF;
9 END m_gebdat_check;
10 /
Trigger created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> INSERT INTO your_table_name (gebdatum) VALUES (SYSDATE + 1)
2 /
1 row created.
scott@ORA92> INSERT INTO your_table_name (gebdatum) VALUES (SYSDATE - 1)
2 /
INSERT INTO your_table_name (gebdatum) VALUES (SYSDATE - 1)
*
ERROR at line 1:
ORA-20001: Birthday must be greater than today
ORA-06512: at "SCOTT.M_GEBDAT_CHECK", line 4
ORA-04088: error during execution of trigger 'SCOTT.M_GEBDAT_CHECK'
|
|
|