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

Experiment 01: Write A PL/SQL Program To Print Hello World

The document contains 5 PL/SQL programming experiments: 1) print Hello World, 2) create a procedure to calculate the product of numbers in a range, 3) create a procedure to return the sum of first 10 natural numbers, 4) create a procedure that takes a salary as INOUT and returns sum of salaries greater than it, 5) create a function to return an employee name from a table.

Uploaded by

Amanpreet Kaur
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Experiment 01: Write A PL/SQL Program To Print Hello World

The document contains 5 PL/SQL programming experiments: 1) print Hello World, 2) create a procedure to calculate the product of numbers in a range, 3) create a procedure to return the sum of first 10 natural numbers, 4) create a procedure that takes a salary as INOUT and returns sum of salaries greater than it, 5) create a function to return an employee name from a table.

Uploaded by

Amanpreet Kaur
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment 01: Write a PL/SQL program to print Hello World.

DECLARE l_message VARCHAR2 (100) := 'Hello'; l_message2 VARCHAR2 (100) := ' World!'; BEGIN IF SYSDATE >= TO_DATE ('01-JAN-2011') THEN l_message2 := l_message || l_message2; DBMS_OUTPUT.put_line (l_message2); ELSE DBMS_OUTPUT.put_line (l_message); END IF; END;

Experiment 02: Write a PL/SQL procedure to create or replace which takes 2 numbers as parameter and displays product of first number till second number.

CREATE OR REPLACE PROCEDURE product( no1 IN number , no2 IN number) IS Result number:=1; begin For i in no1..no2 loop Result:= Result*i; end loop; DBMS_OUTPUT.put_line(Result); end;

Experiment 03: Write a PL/SQL procedure to return a value for finding the sum of first 10 natural numbers using OUT.

CREATE OR REPLACE PROCEDURE sum(s OUT number) IS Result number:=0; BEGIN FOR i in 1..10 LOOP Result:= Result+i; END LOOP; s:=Result; END;

Experiment 04: Write a PL/SQL procedure that takes Sal_amount as INOUT parameter and return the sum of salary of employees getting more salary than input. (Assume Employee relation with attribute salary given).

CREATE OR REPLACE PROCEDURE salary(Sal_amount INOUT number) IS BEGIN SELECT sum(salary) AS Sal_amount WHERE Salary>Sal_amount FROM Employee END;

Experiment 05: Write a PL/SQL program using a function to return the employee name from the employee table

CREATE OR REPLACE FUNCTION employer_details_func RETURN VARCHAR(20); IS emp_name VARCHAR(20); BEGIN SELECT first_name INTO emp_name FROM emp_tbl WHERE empID = '100'; RETURN emp_name; END;

You might also like