To test the following procedures, do the following A. SETTING UP TABLES WITH DATA ----------------------------- 1. Ensure that your DB does not have student and professor tables. You may delete existing tables by: SQL> @dropTables 2. Then create the tables by: SQL> @createTables 3. Create data to be loaded into your tables by executing the script: $ ./createData.pl 4. Load data into tables by executing the script: $ ./loadData.sh THESE ARE THE PROCEDURES ----------------------- testProcedure1.sql -- this procedure copies the table from student into a new table called newStudent -- the number of rows to be copied is specified as a parameter. It requires you have already defined a table called newStudent (SNAME, MAJOR). testProcedure2.sql -- this is invalid because it tries to issue a DDL statement - definining a view. Only DML statements are allowed in the procedure body testProcedure3.sql -- this illustrates the usage of Cursor for update. Again, depending on which OPEN myCursor2 is commented, you will get different results. testFunction1.sql -- this function returns the maximum salary as integer. you can make use of it in a query like: SELECT * from professor where salary = testFunction1 (); testFunction2.sql -- this function is a crazy one. It illustrates %ROWCOUNT. %ROWCOUNT will be one for myCursor (one row has been fetched). So this function will return 80000. ------------------------ The following are some triggers: ------------------------------- 1. trigger1.sql -- prevents insertion of a professor with salary < 70000 2. trigger2.sql -- prevents updating professor where salary decreases. 3. trigger3.sql -- combines the above 2 into 1 trigger 4. trigger4.sql -- simulation of foreign key constraint. Before inserting a student, ensure that there is a corresponding professor. 5. trigger5.sql -- illustrates in stead of triggers. Remember that you cannot insert into a join view that requires insert into multiple tables. CREATE VIEW studentProf (student, professor, salary) AS SELECT sName, pName, salary FROM Student, Professor WHERE advisor=pName; You cannot insert into this view. The trigger defines how to perform inserts on this view.