Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 need help - SQL Assertion

Author  Topic 

mitcho
Starting Member

7 Posts

Posted - 2004-09-21 : 00:03:24
Hey everyone,
I just signed up today as i am new to sql, and have a little problem i was hoping for some feedback.

I have a table called Nurse (see below). Nurse has an attribute called Exp_date which is the expiry date of their license. Their licenses have to be renewed every 2 years so i am trying to write an Assertion to check this (see below). unfortunaltey i am quite new to this and am not sure if it will work. I was wondering if anyone could let me know if it is wrong or if it will work. if it is wrong can i have some suggestions.

here is the Nurse table:
CREATE TABLE Nurse
(
Nurse_ssn varchar(12),
Lic_no varchar(9),
Exp_date date NOT NULL,
CONSTRAINT _PK PRIMARY KEY(Nurse_ssn),
);

here is my assertion to check that the license has been renewed in the last 2 years:CREATE ASSERTION expiry-constraint CHECK
(
SELECT Exp_date
FROM Nurse
((Sysdate - Exp_date)< 2)
);

This assertion is not for a specific database application; im learning from a text book and im not trying to get this to work on a system, im just doing it on paper. its a question im having trouble with.

anyone help me with that?

Thanks for anyone who is willing to help me...

regards,

mitchell page

regards,

mitchell page

mitcho
Starting Member

7 Posts

Posted - 2004-09-21 : 00:06:05
Why are Assertions better suited to express rules such as this? Why not just use check constraints? Can anyone tell me why??

regards,

mitchell page
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-09-21 : 08:33:46
Please don't cross post:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=40147
Go to Top of Page
   

- Advertisement -