Академический Документы
Профессиональный Документы
Культура Документы
Ans:- Declaration
Executable
Execption Handling
begin
dbms_output.put_line('Hello World'); ///// Command to print Anything in Pl
Sql
end;
declare
a varchar(20);
begin
a:='Hello World!';
dbms_output.put_line(a);
end;
declare
a int:=:a;
b int:=:b;
c int;
begin
c:=a+b;
dbms_output.put_line(c);
end;
declare
a int:=:a;
b int:=:b;
c int;
begin
if (a>b)
then
dbms_output.put_line(a);
else
dbms_output.put_line(b);
end if;
end;
end if;
end;
//////////////////////////////////////////////////////////////////////////////////
TRIGGER:
desc t11
desc t12
create or replace trigger trig
After insert on t11
for each row
begin
insert into t12 values(:new.id,:new.name);
end;
insert into t11 values(11813609,'Prashant')
select * from t12
Q:-create a trigger which will insert a row in backup table whenever we delete from
Primary Table?
Ans:-
Q:- Write a PL SQL program which will print the no from 1 to 10?
Ans:-
begin
for i in 1..10
loop
dbms_output.put_line(i);
end loop;
end;
Q:- Reverse
begin
for i in reverse 1..10
loop
dbms_output.put_line(i);
end loop;
end;
///////////////////////////////////////////////////////////////////////////////////
///////////////////////
Q:- Write A pl Sql program which will print factorial of no. and no. should be
taken from users?
Ans:-
declare
a int:=:a;
fac int:=1;
begin
for i in 1..a
loop
fac:=fac*i;
end loop;
dbms_output.put_line(fac);
end;
///////////////////////////////////////////////////////////////////////////////////
//////////////////////
Q:- Write A Pl Sql Program To Print the Following Sequence :-
*
**
***
****
*****
******
Ans:-
declare
n number:=5;
i number;
j number;
begin
for i in 1..n
loop
for j in 1..i
loop
dbms_output.put('*');
end loop;
dbms_output.new_line;
end loop;
end;
WHILE LOOP :-
declare
i int:=10;
begin
while i<10
loop
dbms_output.put(i);
i=i+1;
end loop;
end;
x=mod(n,10)
r=(r+10)
r=trunk(r/10)
while i<10////////////////////////////
declare
num1 number(5);
num2 number(5);
rev number(5);
begin
num1:=:num1;
rev:=0;
while num1>0
loop
num2:=num1 mod 10;
rev:=num2+(rev*10);
num1:=floor(num1/10);
end loop;
dbms_output.put_line('Reverse number is: '||rev);
end;
//////////////////////////////////////////////////////////////////////////
10/8/19
Procedures:-
create or replace procedure Procedure Name(P1)
Parameters(IN,OUT,INOUT)
IS/AS
begin
Procedure Body
end;
begin
N1;
end;
///////////////////////////////
Q:- program to add two no. using Procedure?
Ans:-
///or///
create or replace procedure N2
(a int,b int)
is
c int;
begin
c:=a+b;
dbms_output.put_line('sum='||c);
end;
begin
N2(10,20);
end;
begin
N2(:a,:b);
end;
Q;- Create a procedure which will update the salaries of employees the value should
be
taken from users?
Ans:-
-------------------------------------------------------------
create a function which will display square root of function using in/out???
________________________________________________________________________
Q:-Create a Pl sql function which will return a factorial of a no.??
Ans:-
create or replace function f1(a in int,b in int)
return int
as
begin
if(a=0)
then
return(1)
else
return(a*f1(a-1))
end if;
end;
___________________________________________________________________________________
___________
**Indexing:-
Q:-Consider a harddisk in which block size is 1000 bytes , the record size is 100
bytes
the key fields is of 12 bytes and the pointer is of 8 bytes the harddisk contains a
file of
10000 record find the time complexity without index and with index.
___________________________________________________________________________________
___________
Q:-Write a program which will print the notification message whenever we try to
update,delete
and insert.