-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectSetup.sql
More file actions
executable file
·67 lines (57 loc) · 1.41 KB
/
Copy pathProjectSetup.sql
File metadata and controls
executable file
·67 lines (57 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* File name: ProjectSetup.sql
* Function: to drop & create triggers,indexs, and get ready for
* the Radiology Information System.
*/
CREATE OR REPLACE TRIGGER checkEmail
BEFORE INSERT ON persons
FOR EACH ROW
DECLARE dummy INTEGER;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
SELECT count(*) INTO dummy
FROM persons p
WHERE email = :NEW.email AND
p.person_id <> :NEW.person_id;
IF dummy > 0
THEN
raise_application_error(-20000, 'Duplicate Email!');
END IF;
COMMIT;
END;
/
CREATE OR REPLACE TRIGGER checkUserName
BEFORE INSERT ON users
FOR EACH ROW
DECLARE dummy INTEGER;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
SELECT count(*) INTO dummy
FROM users
WHERE user_name = :NEW.user_name;
IF dummy > 0
THEN
raise_application_error(-20001, 'The user name exists!');
END IF;
COMMIT;
END;
/
DROP TABLE fullname;
DROP INDEX dx;
DROP INDEX des;
CREATE INDEX dx ON radiology_record(diagnosis) INDEXTYPE IS CTXSYS.CONTEXT;
CREATE INDEX des ON radiology_record(description) INDEXTYPE IS CTXSYS.CONTEXT;
set serveroutput on
declare
job1 number;
job2 number;
begin
dbms_job.submit(job1, 'ctx_ddl.sync_index(''dx'');',
interval=>'SYSDATE+0/1440');
dbms_job.submit(job2, 'ctx_ddl.sync_index(''des'');',
interval=>'SYSDATE+0/1440');
commit;
dbms_output.put_line('job1 '||job1||' has been submitted.');
dbms_output.put_line('job2 '||job2||' has been submitted.');
end;
/