Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Dbms Lab Programs

# Dbms Lab Programs

Ratings:
(0)
|Views: 52|Likes:

### Availability:

See more
See less

05/13/2011

pdf

text

original

ITERATIVE CONSTRUCTIONS
WHILE LOOP
Declarey number:=5; beginwhile (y <= 10) loopdbms_output.put_line('hi ');y:=y+1;end loop;end;
SIMPLE LOOP
declarea number:=1; beginloopdbms_output.put_line('hello');exitwhen ( a >= 5 );a := a + 1;end loop;end;
FOR LOOP
declarea number; beginfor a in 1..10loopdbms_output.put_line('hi');end loop;end;

EXCEPTION EXAMPLE
DeclareSalary number ;BeginSelect sal into salary from salary wheresal>6000;ExceptionWhen no_data_found thendbms_output.put_line('salary is not this much');end;

q) write a program to update salary for empno=7369
declarenumb number(5);a number:=5;eno number; beginselect sal into numb from emp where empno=7369;if numb>3000 thenupdate emp set sal=numb+25 where empno=7369;elseupdate emp set sal=numb+250 where empno=7369;end if;end;
q) write a procedure to raise salary for given empno
procedure raisesal(emp_id integer, increase real) iscurrentsal real;salarymissing exception; beginselect sal into currentsal from emp where empno=emp_id;if currentsal is null thenraise salarymissing;elseupdate emp set sal = sal+increase where empno=emp_id;end if;exceptionwhen no_data_found thendbms_output.put_line('no such no');when salarymissing thendbms_output.put_line('no sal');end raisesal;
way of execution:
beginraisesal(7369,500.00);end;