[SOLVED] DBS501/DES720 Lab1 – Lab 8

$25

File Name: DBS501/DES720_Lab1_-_Lab_8.zip
File Size: 244.92 KB

SKU: [Solved] DBS501 Lab1 Category: Tag:
5/5 - (1 vote)
Lab8_12c

1) Walkthrough the following PL/SQL code and try to guess what 3 values will be printed during its execution.

SET SERVEROUTPUT ON

<<big>>

DECLARE

v_mine NUMBER(4) := 500;

BEGIN

<<small>>

DECLARE

v_mine NUMBER(3) := 700;

BEGIN

dbms_output.put_line(Local V_MINE is here: || v_mine);

dbms_output.put_line(Outer V_MINE is here: || big.v_mine);

big.v_mine := v_mine * 2;

END;

dbms_output.put_line(Outer V_MINE is here: || v_mine);

END;

/

 

2) Write a PL/SQL block

  1. That includes declarations for the following variables:
    • A VARCHAR2 datatype that could accept the string Introduction to Oracle Database
    • A NUMBER that may be assigned 123456.78, but not 123456.789 or 1023456.78
    • A CONSTANT that is initialized to the value 704B
    • A BOOLEAN
    • A DATE data type initialized to one week from today (without the hours)
  2. In the body of the block, place a message with values for each of the variables that received an initialization value.
  3. In the body of the block, write a code that will perform following tests use a nested IF THEN ELSE statement when needed
    • Check if the VARCHAR2 variable you created contains the word SQL.
    • If it does, then put a message on the screen that provides the name of the course
    • If it does not, then test to see if the CONSTANT you created contains the room number 704B.
    • If it does, then check whether your VARCHAR2 variable has a value and if yes put a message that states the course name and the room name that youve reached in this logic. Otherwise, put the message Course is unknown and the room name as well.
    • If the CONSTANT does not, then put a message on the screen that states that the Course and location could not be determined.
  4. Assign the VARCHAR2 variable C++ advanced value, just before your IF-THEN logic and observe how the result has changed
  5. Provide BOTH results at the end of this question

3) Perform the following tasks:

  1. Create a table called Lab1_tab with two columns (Id as numeric and LName as variable character of maximum 20 characters)
  2. Create a sequence called Lab1_seq that increments by units of 5 and starts with1.
  1. Write a PL/SQL block that performs the following in this order:
    1. Declares two variables to hold values for columns of table Lab1_tab
    2. The block then inserts into the table the last name of the student that is enrolled in the most classes and his/her last name contains less than 9 characters. Here use a sequence for the Id.
    3. Then the student with the least enrollments is inserted in the table, use sequence as well.
    4. Insert the instructors last name teaching the least amount of courses if his/her last name does NOT end on s. Here do not use the sequence to generate the ID; instead use your first variable.
    5. Now insert the instructor teaching the most number of courses and use the sequence to populate his/her Id.
    6. Save your changes and display the content of your table Lab1_tab
    7. You will need to plan for the Exception when more than one student is enrolled in the Maximum (Minimum) number of courses. Same for the Instructor teaching Maximum (Minimum) number of courses. The message stored in the table in that case should be Multiple Names (instead of the last name).

Hint: You may use ONE outer block and FOUR INNER blocks (each of them with its EXCEPTION section) followed by the appropriate INSERT statement.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] DBS501/DES720 Lab1 – Lab 8
$25