0% found this document useful (0 votes)
5 views5 pages

PL SQL Programs

Uploaded by

efxzzgz639
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
5 views5 pages

PL SQL Programs

Uploaded by

efxzzgz639
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

PL/SQL PROGRAMS

-- To print string we use single quotation


Begin
dbms_output.put_line('welcome to PL/SQL programming');
end;
/______________________________________________
-- To enter the value of variable using command line
DECLARE
a integer;
BEGIN
a:=&a;
dbms_output.put_line('Value of a is: ' || a);
end;
/
output:
Enter value for a: 10
old 4: a:=&a;
new 4: a:=10;
Value of a is: 10
PL/SQL procedure successfully completed.
__________________________________________________
Note: we can use set verify off to switch off the new and old
value display
SQL> SET VERIFY OFF;
SQL> set serveroutput on;
____________________________________________________
-- To initialize variables
DECLARE
a number :=10;
b number :=20;
c number;
BEGIN
c:=a+b;
dbms_output.put_line('Value of c is: ' || c);
end;
/
__________________________________________________
-- Addition of two numbers
DECLARE
a integer := 30;
b integer := 40;
c integer;
f real;
BEGIN
c := a + b;
dbms_output.put_line('Value of c: ' || c);
f := 100.0/3.0;
dbms_output.put_line('Value of f: ' || f);
END;
/_______________________________________________
DECLARE
name varchar2(20):='&name';
BEGIN
dbms_output.put_line('Entered name is: ' || name);
end;
__________________________________________________
DECLARE
N NUMBER;
M NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('ENTER A NUMBER');
N:=&NUMBER;

DBMS_OUTPUT.PUT_LINE('ENTER A NUMBER');
M:=&NUMBER;
IF N<M THEN
DBMS_OUTPUT.PUT_LINE(''|| N ||' IS GREATER THAN '||
M ||'');
ELSE
DBMS_OUTPUT.PUT_LINE(''|| M ||' IS GREATER THAN '||
N ||'');
END IF;
END;
/
___________________________________________________

You might also like