1) Sample program for pl/sql block declare x number:=10; y number:=20; begin z:=x+y; dbms_output.

put_line('Addition Result is-->' z); end; / 2) Program for take run time values declare x number:=&x; y number:=&y; begin z:=x+y; dbms_ouput.put_line(z); end; / 3) Program for if condition delcare x number:=&x; y number:=&y; begin if x < y then dbms_output.put_line('y is big'); else dbms_output.put_line('x is big'); end if; end; 4) Program for do while declare i number:=1; begin loop dbms_output.put_line(i); i:=i+1; exit when i>=100; end loop; end; / 5) Program for " while loop" decalre i number:=1; begin while i<=100 loop dbms_output.put_line(i); i:=i+1; end loop; end; /

sfee into stuName.100 loop dbms_output.y number(6)) as z number:=0.put_line('Student Name is-->' sname).sid%type:=&sid. / 10) Write a procedure for adding two numbers .sfee%type. end loop. enam varchar2(20). stuName Student. end. end. dbms_output.studentfee from student based student id and w ith variables as table's data types only.put_line('Student Fee is-->' sfee). begin select ename in to enam where empId=eid.put_line(x). begin z:=x+y.put_line('The KishAdd procudere result is--> z).6) Program for "For Loop" delcare x number:=1.put_line(x).sname%type.stuFee from Student where sid=studId.put_line('employee name is--->' enam). / 11) write a function for adding two numbers and return the result back . stuFee Student. end. declare studId Student. dbms_output.. dbms_output. begin for k in x. / 7) Program for "For loop in reverse" declare x number:=1.. create or replace procedure KishAdd(x number(6). begin for x in reverse x. end loop. begin select sname. end. dbms_output.100 loop dbms_output. / 8) Program for select ename from employee table based on empid declare eid number:=&eid. / 9) Program for select studentname. end.

//no condition so all rows updated in tabl e student rename student to students.'&sname'. //removing the column from student table alter table student rename sloc to studLocation .sname from student. // renaming the old columnname to new column name deltee from student.'&sloc').&sfee.'sai'. //for insert multiple r ows at a time alter table student add column sdob varchar2(20). //updating the new values based on new values.1000. //selecting the records whose name starts with k. //selecting only satisfied rows only select * from student where sname like 'K%' . update student set sname='kishore' where sid=1.sloc varcha r2(20)). //adding new column to existi ng table alter table student modify sname varchar2(50). // for all rows deleted delete from student where sid=1. insert into student values('1'.sfee number(5). begin z:=x+y. / -------------------------------------------------------------------------------------------------------------------------------------------------------SQL Commands :----------------create table student(sid number(5). //selecing perticular columns select * from student where sid=1. //perticular student record is deleted truncate table student. return z. //changed the table name student to students select * from student.sname varchar2(20).'hyd'). //for one row command insert into student values(&sid. // u will get error because above command for changed th e table name select * from students. update student set sname='kishore' .y number(6)) return number as z number:=0. // all rows at a time deleted from table but structure i s exists. end. //modifying the column size to mo re means 20 to 50 alter table student drop column sfee. '%' means later k may have any no of characters .create or replace function KisAddFun(x number(5). // u will get all the information of student table select sid.

't') from dual.ascii('k'). //dual is tabl e for execute the functions Char functions :----------------select chr(90).variance(sid).5). '_' means later k only one letter.replace('kis hore'.length('kis hore') from dual r student r any table name.select * from student where sname like 'K_%.add_months('1-aug-2011'.lower('KISHORE').substr('kishore'.3).3.'k'.max(sid).chepuri').'thursday') from dual.'1-jun-11').avg(sid).upper('kishore'). . Date Functions :-----------------select months_between('1-aug-11'.substr('kishore'.min(sid). select sqrt(4) from student. -----------------------------------------------------------------Agreegate functions :-----------------------select sum(sid).2). // same as select sqrt(4) from dual. //selecting the records whose name starts with k. select concate('Kishore'.last_day ('1-aug-2011').stddev(sid) from studen t. so one '_' for one char.next_day('18-aug-2011'.