Database Management System Lab Report Name: CH - Gopi Reg - No:18Bce7212 SLOT: L39+L40 Topic: PL / SQL Cursors Procedure Table
Database Management System Lab Report Name: CH - Gopi Reg - No:18Bce7212 SLOT: L39+L40 Topic: PL / SQL Cursors Procedure Table
LAB REPORT
NAME : CH.GOPI REG.NO:18BCE7212
SLOT : L39+L40
Topic : PL / SQL Cursors Procedure
Table:
Exercise Problems:
1)Write a PL/SQL block to calculate the incentive of an employee
whose ID is 110.
solution:
2) Write a PL/SQL block to show an invalid case-insensitive
reference to a quoted and without quoted user-defined
identifier.
Solution:
3) Write a PL/SQL block to show a reserved word can be used as
a user-define identifier.
Solution:
4) Write a PL/SQL block to show the result to neglect double
quotation marks in reserved word identifier.
Solution:
5) Write a PL/SQL block to show the result to neglect the case
sensitivity of a user defined identifier which is also a reserved
word.
Solution:
6) Write a PL/SQL block to explain single and multiline
comments.
Solution:
7) Write PL/SQL blocks to show the declaration of variables.
Solution:
8) Write PL/SQL blocks to show the scope and visibility of local
and global identifiers.
Code:
DECLARE
var_a INTEGER;
var_b REAL;
BEGIN
var_a:=5;
var_b:=10.25;
DBMS_OUTPUT.PUT_LINE('In the Outer Block');
DBMS_OUTPUT.PUT_LINE('var_a = ' || var_a);
DBMS_OUTPUT.PUT_LINE('var_b = ' || var_b);
DECLARE
var_a CHAR;
var_c REAL;
BEGIN
var_a:='C';
var_c:=15.50;
DBMS_OUTPUT.PUT_LINE('In the First sub-Block');
DBMS_OUTPUT.PUT_LINE('var_a = ' || var_a);
DBMS_OUTPUT.PUT_LINE('var_b = ' || var_b);
DBMS_OUTPUT.PUT_LINE('var_c = ' || var_c);
NULL;
END;
DECLARE
var_d REAL;
BEGIN
var_d:=20.75;
DBMS_OUTPUT.PUT_LINE('In the Second sub-Block');
DBMS_OUTPUT.PUT_LINE('var_a = ' || var_a);
DBMS_OUTPUT.PUT_LINE('var_b = ' || var_b);
DBMS_OUTPUT.PUT_LINE('var_d = ' || var_d);
NULL;
END;
DBMS_OUTPUT.PUT_LINE('At the end in the Outer-Block');
DBMS_OUTPUT.PUT_LINE('var_a = ' || var_a);
DBMS_OUTPUT.PUT_LINE('var_b = ' || var_b);
END;
/
Output:
9) Write a PL/SQL block to show a valid case-insensitive
reference to a quoted and without quoted user-defined
identifier.
10) Write a PL/SQL block to adjust the salary of the employee
whose ID 122.
Code:
DECLARE
salary_of_emp NUMBER(8,2);
PROCEDURE approx_salary (emp NUMBER,empsal IN OUT
NUMBER,addless NUMBER)
IS
BEGIN
empsal := empsal + addless;
END;
BEGIN
SELECT salary INTO salary_of_emp
FROM employees
WHERE employee_id = 122;
DBMS_OUTPUT.PUT_LINE('Before invoking procedure,
salary_of_emp: ' || salary_of_emp);
approx_salary (100, salary_of_emp, 1000);
DBMS_OUTPUT.PUT_LINE('After invoking procedure,
salary_of_emp: ' || salary_of_emp);
END;
/
Output: