0% found this document useful (0 votes)
6 views

PLSQL Homework 1

Uploaded by

kiraningale48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

PLSQL Homework 1

Uploaded by

kiraningale48
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PLSQL

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.

2. WHAT IS SET SERVEROUTPUT ON?


ANS : SET SERVEROUTPUT ON is a SQLPlus command used in Oracle databases to
enable the display of output from PL/SQL blocks.
When you run a PL/SQL block that contains calls to DBMS_OUTPUT.PUT_LINE (a
procedure used to print messages to the console), the output will be shown in the
SQLPlus console only if SET SERVEROUTPUT ON is enabled.

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.

5. what are the opertors used in PLSQL?


---1. Arithmetic Operators
---2. Comparison Operators
---3. Logical Operators
---4. String Operators
---5. Set Operators

6. Write a code to multiply the number 10,30?

>>SET SERVEROUTPUT ON;

DECLARE
v_out NUMBER(10);
BEGIN
SELECT
10 * 30
INTO v_out
FROM
dual;

dbms_output.put_line('MULTIPLICATION =' || v_out);


END;
7. Write a code to multiply the numbber 10,20,40,60 and add 10,50?

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;
9. Data type used in PLSQL?
---1. Scalar Data Types
---2. Composite Data Types
---3. Large Object (LOB) Data Types
---4. Reference Data Types
---5. User-Defined Data Types

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);


first_name VARCHAR2 (25);

last_name VARCHAR2 (25);

salary NUMBER (10);

job_id VARCHAR2 (10);

email VARCHAR2 (25);

BEGIN

SELECT employee_id,first_name,last_name,salary,job_id,email INTO


employee_id,first_name,last_name,salary,job_id,email FROM HR.EMPLOYEES
WHERE employee_id =131;

DBMS_OUTPUT.PUT_LINE ('employee_id ='||employee_id||'___' ||'first_name


='||first_name||'___'||'last_name ='||last_name||'____'||'salary ='||salary
||'____'||'job_id ='||job_id||'____'||'email ='||email );

END;

You might also like