Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PL / SQL homewerk help needed. I ' m using SQL developer. Please use PL / SQL and use SQL Developer Here is the questions
PLSQL homewerk help needed. Im using SQL developer. Please use PLSQL and use SQL Developer Here is the questions below: The Raise Procedure points Create a copy of the EMPLOYEES table by running the following code: CREATE TABLE MyEmployees AS SELECT FROM HREmployees; Now, create a new table that you will use for logging CREATE TABLE HWLog Message VARCHAR TStamp TIMESTAMP DEFAULT SYSTIMESTAMP ; Notice that the TStamp column was created with a default value. You can add a log message to the table like this: INSERT INTO HWLog Message VALUES Some message'; If you look at the table now, youll see that the timestamp column has been populated automatically. Later on youll be asked to use code like this to write messages to your log table. Now, create a stored procedure called RaiseSalary that accepts two parameters an employee id and an integer raise percentage. The procedure will raise the salary of the specified employee by the specified percentage. It will do this by updating the Salary column in MyEmployees. Calling the procedure with an argument of for the employee id and for the raise percentage would raise that employees salary by percent. Your procedure should include exception handling. It should have a generic error handler which prints out both the SQLERRM and the phrase Encountered while trying to give employee a raise. Of course, instead of your error message should include the value of the employee id parameter that was passed into the procedure. Every time your procedure raises the salary of an employee, you should write a message to your HWLog table in the following form: Employee was raised by percent. Note that an UPDATE statement that affects zero records wont cause an exception. Implicit cursor attributes can help you determine if anybodys salary was actually raised. Do a COMMIT; inside your procedure after all the other code in the BEGIN section but before EXCEPTION to make your changes public and permanent. Its not always a good idea to have a COMMIT inside your procedures, but for the sake of this exercise, please put one in there. Show the code for your procedure, as well as the code and output from the following exercises: Show the initial salary of employee can do this with a standard SQL query Call your procedure with an employee id of and a percentage of Show the salary of employee after the procedure call can do this with a standard SQL query Show the initial salary of employee can do this with a standard SQL query Call your procedure with an employee id of and a percentage of Show the salary of employee after the procedure call can do this with a standard SQL query Call your procedure with an employee id of and a percentage of Show all of the data from your HWLog table can do this with a standard SQL query order your results by ascending TStamp value.
PLSQL homewerk help needed. Im using SQL developer. Please use PLSQL and use SQL Developer
Here is the questions below:
The Raise Procedure points
Create a copy of the EMPLOYEES table by running the following code:
CREATE TABLE MyEmployees AS SELECT FROM HREmployees;
Now, create a new table that you will use for logging
CREATE TABLE HWLog
Message VARCHAR
TStamp TIMESTAMP DEFAULT SYSTIMESTAMP
;
Notice that the TStamp column was created with a default value. You can add a log message to the table like this:
INSERT INTO HWLog Message VALUES Some message';
If you look at the table now, youll see that the timestamp column has been populated automatically. Later on youll be asked to use code like this to write messages to your log table.
Now, create a stored procedure called RaiseSalary that accepts two parameters an employee id and an integer raise percentage. The procedure will raise the salary of the specified employee by the specified percentage. It will do this by updating the Salary column in MyEmployees. Calling the procedure with an argument of for the employee id and for the raise percentage would raise that employees salary by percent.
Your procedure should include exception handling. It should have a generic error handler which prints out both the SQLERRM and the phrase Encountered while trying to give employee a raise. Of course, instead of your error message should include the value of the employee id parameter that was passed into the procedure.
Every time your procedure raises the salary of an employee, you should write a message to your HWLog table in the following form:
Employee was raised by percent.
Note that an UPDATE statement that affects zero records wont cause an exception. Implicit cursor attributes can help you determine if anybodys salary was actually raised.
Do a COMMIT; inside your procedure after all the other code in the BEGIN section but before EXCEPTION to make your changes public and permanent. Its not always a good idea to have a COMMIT inside your procedures, but for the sake of this exercise, please put one in there.
Show the code for your procedure, as well as the code and output from the following exercises:
Show the initial salary of employee can do this with a standard SQL query
Call your procedure with an employee id of and a percentage of
Show the salary of employee after the procedure call can do this with a standard SQL query
Show the initial salary of employee can do this with a standard SQL query
Call your procedure with an employee id of and a percentage of
Show the salary of employee after the procedure call can do this with a standard SQL query
Call your procedure with an employee id of and a percentage of
Show all of the data from your HWLog table can do this with a standard SQL query order your results by ascending TStamp value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started