Taller 5
Taller 5
1. Execute the command (CREATE TABLE MESSAGES (RESULTS INTEGER); )to create the messages table. Write a PL/SQL block to insert numbers into the messages table. A. Insert the numbers 1 to 10, excluding 6 and 8. B. Commit before the end of the block. C. Execute a SELECT statement to verify that your PL/SQL block worked. You should see the following output:
2. Execute the script (CREATE TABLE EMP AS (SELECT * FROM HR.EMPLOYEES); ). This script creates an emp table that is a replica of the employees table. Alter the emp table to add a new column, stars, of VARCHAR2 data type and size 50. Create a PL/SQL block that inserts an asterisk in the stars column for every $1,000 of the employees salary. Save your script as lab_05_02_soln.sql. A. In the declarative section of the block, declare a variable v_empno of type emp.employee_id and initialize it to 176. Declare a variable v_asterisk of type emp.stars and initialize it to NULL. Create a variable sal of type emp.salary. B. In the executable section, write logic to append an asterisk (*) to the string for every $1,000 of the salary amount. For example, if the employee earns
$8,000, the string of asterisks should contain eight asterisks. If the employee earns $12,500, the string of asterisks should contain 13 asterisks. C. Update the stars column for the employee with the string of asterisks. Commit before the end of the block.