Re: Need Help With an Update Script
- From: --CELKO-- <jcelko212@xxxxxxxxxxxxx>
- Date: Wed, 28 May 2008 10:43:43 -0700 (PDT)
That sounds pretty complicated. <<
It is a lot easier than what you are trying to do. Why do you keep
thinking about procedural instead of declarative code, materialized
data instead of virtual? This is SQL, not COBOL. Build a base table
and make sure that it follows your business rules
CREATE TABLE Patients
( ..
admit_date DATETIME NOT NULL,
discharge_date DATETIME NOT NULL,
CHECK (discharge_date = DATEADD(DAY, 3, admit_date)),
,..);
Now just show this to the users:
CREATE VIEW CurrentPatients (., admit_date, discharge_date, ..)
AS
SELECT .., admit_date,
CASE WHEN discharge_date <= CURRENT_TIMESTAMP
THEN discharge_date ELSE NULL END AS discharge_date,
...
FROM Patients;
No scripts, triggers, proprietary transaction syntax, host language
procedures, etc.
.
- Follow-Ups:
- Re: Need Help With an Update Script
- From: preet
- Re: Need Help With an Update Script
- References:
- Need Help With an Update Script
- From: alvinstraight38@xxxxxxxxxxx
- Re: Need Help With an Update Script
- From: --CELKO--
- Re: Need Help With an Update Script
- From: alvinstraight38@xxxxxxxxxxx
- Need Help With an Update Script
- Prev by Date: Re: Need Help With an Update Script
- Next by Date: Re: Need Help With an Update Script
- Previous by thread: Re: Need Help With an Update Script
- Next by thread: Re: Need Help With an Update Script
- Index(es):