- 1.Write a PL/SQL block to calculate the incentive of an employee whose ID is 110.
- DECLARE
- v_incentive number(8,2);
- BEGIN
- select salary * 0.15 into v_incentive
- from employees
- where employee_id = 110;
- dbms_output.put_line('Incentive = '||v_incentive);
- END;
- 2.Write a PL/SQL block to show an invalid case-insensitive reference to a quoted and without quoted user-defined identifier.
- QUOTED USER-IDENTIFIER
- DECLARE
- "HELLO" varchar2(10) :='Hello';
- BEGIN
- dbms_output.put_line("Hello");
- END;
- WITHOUT QUOTED USER-IDENTIFIER
- DECLARE
- HELLO varchar2(10) :='Hello';
- BEGIN
- dbms_output.put_line("Hello");
- END;
- 3.Write a PL/SQL block to show a reserved word can be used as a user-define identifier.
- DECLARE
- "DECLARE" varchar2(25) :='UPPERCASE DECLARE';
- "Declare" varchar2(25) :='Declare with uppercase D';
- "declare" varchar2(25) := 'lowercase declare';
- BEGIN
- dbms_output.put_line("HELLO");
- dbms_output.put_line("Hello");
- dbms_output.put_line("hello");
- END;
- 4.Write a PL/SQL block to show the result to neglect double quotation marks in reserved word identifier.
- DECLARE
- "HELLO" varchar2(25) :='hello';
- "DECLARE" varchar2(25) :='declare';
- BEGIN
- dbms_output.put_line(Hello);
- dbms_output.put_line(DECLARE);
- END;
- 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.
- DECLARE
- "HELLO" varchar2(10) := 'hello';
- "DECLARE" varchar2(10) := 'declare';
- BEGIN
- DBMS_Output.Put_Line(Hello);
- DBMS_Output.Put_Line("Declare");
- END;
- 6.Write a PL/SQL block to explain single and multiline comments.
- DECLARE
- v_name varchar2(25) :='Danail'; --we declare name and this is single line comment
- BEGIN
- dbms_output.put_line(v_name); /*we use this commant to display the name.
- and this is multi line comment*/
- END;
- 7.Write PL/SQL blocks to show the declaration of variables.
- DECLARE
- v_firstName varchar2(20) :='Danail';
- v_lastName varchar2(20) :='Zlatarov';
- v_age number(2) :=27;
- BEGIN
- NULL;
- END;
- 8.Write PL/SQL blocks to show the scope and visibility of local and global identifiers.
- 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;
- 9.Write a PL/SQL block to show a valid case-insensitive reference to a quoted and without quoted user-defined identifier.
- --QUOTED USER-IDENTIFIER
- DECLARE
- "HELLO" varchar2(10) :='Hello';
- BEGIN
- dbms_output.put_line("HELLO");
- END;
- --WITHOUT QUOTED USER-IDENTIFIER
- DECLARE
- HELLO varchar2(10) :='Hello';
- BEGIN
- dbms_output.put_line(HELLO);
- END;
- 10. Write a PL/SQL block to adjust the salary of the employee whose ID 122.
- DECLARE
- v_emplSalary Number(8,2);
- PROCEDURE adjust_salary(
- employee_salary IN OUT NUMBER,
- adjust NUMBER
- ) IS
- BEGIN
- employee_salary :=employee_salary + adjust;
- END;
- BEGIN
- SELECT salary INTO v_emplSalary
- FROM employees
- WHERE employee_id = 122;
- DBMS_OUTPUT.PUT_LINE
- ('Before invoking procedure, v_emplSalary: ' || v_emplSalary);
- adjust_salary (v_emplSalary, 1000);
- DBMS_OUTPUT.PUT_LINE
- ('After invoking procedure, adjust_salary: ' || v_emplSalary);
- END;
[text] answ
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: