0% found this document useful (0 votes)
61 views2 pages

Taller 5

The document provides instructions for two SQL exercises: 1. Create a MESSAGES table and insert numbers 1-10 excluding 6 and 8 using a PL/SQL block. Commit and verify the data with a SELECT statement. 2. Create an emp table from the HR.EMPLOYEES table. Add a stars column and use a PL/SQL block to insert asterisks into stars based on the employee's salary, with each asterisk representing $1,000 of salary. The block declares variables for employee ID, stars string, and salary and appends asterisks to stars based on salary, then updates and commits the record.

Uploaded by

dpp0881
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views2 pages

Taller 5

The document provides instructions for two SQL exercises: 1. Create a MESSAGES table and insert numbers 1-10 excluding 6 and 8 using a PL/SQL block. Commit and verify the data with a SELECT statement. 2. Create an emp table from the HR.EMPLOYEES table. Add a stars column and use a PL/SQL block to insert asterisks into stars based on the employee's salary, with each asterisk representing $1,000 of salary. The block declares variables for employee ID, stars string, and salary and appends asterisks to stars based on salary, then updates and commits the record.

Uploaded by

dpp0881
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ESCRIBIR ESTRUCTURAS DE CONTROL 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.

You might also like