Oracle PL/SQL Programming
What is SQL?
SQL is a command for query or DML purposes. It is run from the Oracle SQL command prompt. Sometimes SQL is written using the notepad or toad software, then saved and run.
What is PL/SQL?
PL/SQL is an extension to SQL for the purpose of programming. Any problem can be solved using the business logic performed by the talent programmer.
PL/SQL is written using the notepad or toad software, then saved and run.
1. Write a PL/SQL program for finding the result of a formula
SET ECHO OFF
set serveroutput ON
declare
x number(7) :=0;
a number(5) :=0;
b number(5) :=0;
begin
a :=8;
b :=6;
x :=(a-b)**2+2*A*B;
dbms_output.put_line('RESULT is: ' || x );
end;
/
2. Write a PL/SQL program to calculate any given basic as input
/* Remember that here, basic salary will accept from the user level */
SET ECHO OFF
set serveroutput ON
DECLARE
v_basic number(6) :=0;
h_rent number (6) :=0;
med_all number(5) :=0;
p_f number (5) :=0;
v_welfare_fund number(2) :=90;
v_salary number(7) :=0;
BEGIN
v_basic:=&v_basic;
h_rent :=v_basic*(0.5);
p_f :=v_basic*(0.1);
med_all :=v_basic*(0.1);
v_salary := v_basic+h_rent+med_all-p_f-v_welfare_fund;
dbms_output.put_line('Your net salary is: ' || v_salary);
END;
/
3. Write a PL/SQL program to calculate the area of a circle.
/* Remember that here, r will be radius as input, pi=3.14 as constant value*/
SET ECHO OFF
set serveroutput ON
DECLARE
v_pi constant number(4,2):=3.14;
v_redius number(3);
v_area number(10,2);
BEGIN
v_redius:=&v_redius;
v_area :=v_pi * power(v_redius,2);
dbms_output.put_line('Calculated area of the circle is: ' || v_area);
END;
/
NB: You can put your comments
The writer is an Oracle Certified Professional (OCP), trainer, innovator, researcher, and consultant. You can be contacted at the mail# rashid.eee.cse@gmail.com
New window for learning PL/SQL program
ReplyDeleteYes. I shall try to explore my effort to all over the world.
DeleteSimple and precise statement..........carry on sir.
ReplyDelete