PLSQL Homework 3
PLSQL Homework 3
HOMEWORK 1
17-05-2024
1 What is anonymous block in PLSQL?
ANS : An unnamed PL/SQL code block (code not stored in the database as a
procedure, function, or package) is known as an anonymous block.
It is a standalone block of code that can be executed directly in an Oracle
database without being stored in the database. These blocks are primarily used
for scripting, testing, or quick, ad-hoc tasks.
3. WHAT Is DBM_OUTPUT.PUT_LINE?
ANS : The DBMS_OUTPUT package enables you to send messages from stored
procedures, packages, and triggers.
The PUT and PUT_LINE procedures in this package enable you to place
information in a buffer that can be read by another trigger, procedure, or
package.
4. What is varible?
ANS : Variables are used to store temporary data that can be manipulated and
used within the PL/SQL block during its execution. They can store various types of
data such as numbers, characters, dates, and more.
DECLARE
v_out NUMBER(10);
BEGIN
SELECT
10 * 30
INTO v_out
FROM
dual;
8. Write a code to multiply the numbber 10,20,40,60 and add 10,50 and
substract 5000-200?
>>DECLARE
V_OUT NUMBER (10);
V1_OUT NUMBER (10);
V2_OUT NUMBER (10);
BEGIN
SELECT 10*20*40*60 , 10+50,5000-200 INTO V_OUT ,V1_OUT,V2_OUT FROM
DUAL;
DBMS_OUTPUT.PUT_LINE ('MULTIPLICATION =' || V_OUT ||'____'|| 'ADDITION
='||V1_OUT||'____'||'SUBTRACTION ='||V2_OUT);
END;
10. Write a plsql block for the employee whose salary is 24000? output column
should be employee_id,first_name,last_name,salary?
11. write a plsql block for the employee whose last name is Mikkilineni?output
column should be employee_id,first_name,last_name,salary,job_id,email?
12. write a plsql block for the employee whose employee id is 131? output
column should be employee_id,first_name,last_name,salary,job_id,email?
>>DECLARE
employee_id NUMBER (10);
BEGIN
END;
HOMEWORK 2
22-05-2024
1. Write a plsql block to add 10,20,40,60,90 number.
2. Write a plsql block to multiply 10,20,60,40 number.
3. Write a plsql block to fetch salary for the employee whose employee_id = 100?
4. Write a plsql block to fetch first_name,last_name,job_id for the employee
whose email id is 'LDEHAAN'?
7. Write a plsql block to update first_name is 'Jack' and last name is 'sparrow' for
the employees whose employee id is 103.
8. Write a plsql block to update salary with 5000 whose last_name is 'Ernst' if
last_name is not matching then update 2000 for employee first_name is 'Bruce'?--
IF -THEN-ELSE
>>if last name MATCHING
10. Write a plsql block to fetch all records from employee_25 table for the
employee_id = 140?
11. Write a plsql block to fetch employee_id,first_name,last_name from
employees for first_name = Neena?
%ROWTYPE Attribute
Purpose: %ROWTYPE is used to declare a record variable that can hold an entire
row of data from a table or a row fetched from a cursor.
Usage: It is useful when you need to work with an entire row of data from a table
or the result set of a query.
HOMEWORK
1. Write a plsql block to fetch salary for the employee whose employee_id is
100,101,102?
>>begin
for QR in (select employee_id,salary from emp where employee_id in
(100,101,102))
loop
DBMS_OUTPUT.PUT_LINE('SALARY OF EMPLOYEE_ID '||QR.employee_id ||' IS
'||QR.salary);
END LOOP;
END;
2. Write a plsql block to fetch first_name,last_name,job_id for the employee
whose email id is 'LDEHAAN','AHUNOLD','NGREENBE'?
10 write q plsql block to fetch and update first_name is 'JOE' and last name is
'TURMA' whose employee_id is 198 and first_name is Jennifer?
11. Write a plsql block to delete the records for the employees whose detail
contain only email - 'KFEENEY' and employee_id - 197?
12. Write a plsql block to to fetch salary data between 10000 and 50000?
13. Write a plsql block to to fetch salary data between 10000 and 50000?--
without using between clouse.
14. Write a plsql block to fetch salary - 17000,4800,7900,2700,3100?
16. Write a plsql block to fetch records from COMMISSION_PCT columns where
values having NULL.
17. Write a plsql block to fetch records from COMMISSION_PCT columns where
values having NOT NULL.