Você está na página 1de 8

(DATABASE MANAGEMENT SYSTEMS 2)

EXERCISE

3
Interacting with Oracle Database Server and Writing
Control Structures

Name of Student Name of Professor


Data Performed Date Submitted
I. OBJECTIVES

At the end of this exercise, students must be able to:

Cognitive
a.) understand the topics they have learned from lessons 5-6.
.
Psychomotor:
a.) embed DML and transaction control statements in PL/SQL.
b.) use SQL cursor attributes.
c.) perform conditional actions by using IF statements.
d.) perform iterative steps by using LOOP structures.
e.) write, test, and execute PL/SQL blocks.

Affective
a.) appreciate the concept behind this exercise.

II. BACKGROUND INFORMATION

In order to accomplish this exercise, the student must have a clear understanding of the
following topics:
 Embed DML statements, transaction control statements, and DDL statements in
PL/SQL.
 The INTO clause, which is mandatory for all SELECT statements in PL/SQL.
 Implicit cursors and explicit cursors.
 SQL cursor attributes.
 Conditional statements (IF and CASE statement).
 Loops, exit, and continue statements.

III.PROCEDURES

1. Execute the script that follows:

Set all the values of the stars column to null.


Create a PL/SQL block that updates an asterisk in the stars column for every $1,000 of
the employee’s salary (given that you had make an emp table with ‘stars’ as one of the
columns).
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 a code that would store in the star column an
asterisk (*) 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.
d. Display the row from the emp table to verify that your PL/SQL block executed
successfully.
e. Execute and save your script as lab_03_04_soln.sql. The following should be the
output:

(DATABASE MANAGEMENT SYSTEMS 2)

EXERCISE

3
Interacting with Oracle Database Server and Writing
Control Structures

Name of Student Name of Professor


Data Performed Date Submitted
IV. OBJECTIVES

At the end of this exercise, students must be able to:

Cognitive
b.) understand the topics they have learned from lessons 5-6.
.
Psychomotor:
f.) embed DML and transaction control statements in PL/SQL.
g.) use SQL cursor attributes.
h.) perform conditional actions by using IF statements.
i.) perform iterative steps by using LOOP structures.
j.) write, test, and execute PL/SQL blocks.

Affective
b.) appreciate the concept behind this exercise.

V. BACKGROUND INFORMATION

In order to accomplish this exercise, the student must have a clear understanding of the
following topics:
 Embed DML statements, transaction control statements, and DDL statements in
PL/SQL.
 The INTO clause, which is mandatory for all SELECT statements in PL/SQL.
 Implicit cursors and explicit cursors.
 SQL cursor attributes.
 Conditional statements (IF and CASE statement).
 Loops, exit, and continue statements.

VI. PROCEDURES

2. Execute the script that follows:

Set all the values of the stars column to null.


Create a PL/SQL block that updates an asterisk in the stars column for every $1,000 of
the employee’s salary (given that you had make an emp table with ‘stars’ as one of the
columns).
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 a code that would store in the star column an
asterisk (*) 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.
d. Display the row from the emp table to verify that your PL/SQL block executed
successfully.
e. Execute and save your script as lab_03_04_soln.sql. The following should be the
output:

VI. Assessment

Department Information Technology


Subject Code ITESPEC1
Description Database Management Systems 2
Term/Academic Year 1 / SY20162017

Topic Interacting with Oracle Database


Server and Writing Control
Structures
Lab Activity No 3
Lab Activity Interacting with Oracle Database
Server and Writing Control
Structures
CLO 1

CRITERION 25 POINTS 20 POINTS 15 POINTS 0 POINT

TOTAL 100 80 60 0
Delivery The lab exercise was The lab exercise was The lab exercise was more There is no lab
delivered on time. delivered within 1 day of the than 2 or more days exercise
due date. overdue. submitted

Knowledge / The student was able The student was able to The student was able to The student was
Understanding to understand the understand the concept and understand the concept and not able to
concept and followed but did not entirely follow the did not follow the understand the
the instructions instructions, and was able to instructions totally, and was exercise at all.
carefully. grasp the whole concept. not able to grasp the
concept.
Completeness Answered all Answered 80% of the Answered below 80% of the Did not answer at
questions. questions and submitted even questions and submitted all. The
the exercise is not yet even the exercise is not yet submitted
complete. complete. exercise was
blank.
Content The answers are short The answers are too long and The answers are short and No answers at all.
but on point to the created a confusion to the idea make no sense at all
correct idea. the student wants to pertain.

V. REFERENCES

Serhal, L., Srivastava, T. (2009). Oracle Database 11g: PL/SQL Fundamentals, Oracle,
California, USA.

VI. Assessment

Department Information Technology


Subject Code ITESPEC1
Description Database Management Systems 2
Term/Academic Year 1 / SY20162017

Topic Interacting with Oracle Database


Server and Writing Control
Structures
Lab Activity No 3
Lab Activity Interacting with Oracle Database
Server and Writing Control
Structures
CLO 1
CRITERION 25 POINTS 20 POINTS 15 POINTS 0 POINT

TOTAL 100 80 60 0
Delivery The lab exercise was The lab exercise was The lab exercise was more There is no lab
delivered on time. delivered within 1 day of the than 2 or more days exercise
due date. overdue. submitted

Knowledge / The student was able The student was able to The student was able to The student was
Understanding to understand the understand the concept and understand the concept and not able to
concept and followed but did not entirely follow the did not follow the understand the
the instructions instructions, and was able to instructions totally, and was exercise at all.
carefully. grasp the whole concept. not able to grasp the
concept.
Completeness Answered all Answered 80% of the Answered below 80% of the Did not answer at
questions. questions and submitted even questions and submitted all. The
the exercise is not yet even the exercise is not yet submitted
complete. complete. exercise was
blank.
Content The answers are short The answers are too long and The answers are short and No answers at all.
but on point to the created a confusion to the idea make no sense at all
correct idea. the student wants to pertain.

VI. REFERENCES

Serhal, L., Srivastava, T. (2009). Oracle Database 11g: PL/SQL Fundamentals, Oracle,
California, USA.

Você também pode gostar