functions in dbms
functions in dbms
RETURN NUMBER IS
BEGIN
RETURN (A*A);
END FUN;
DECLARE
X NUMBER:=:X;
S NUMBER;
BEGIN
S:=FUN(X);
DBMS_OUTPUT.PUT_LINE('SQUARE OF A NUMBER '|| S);
END;
/
functions:
A function is a self contained block that carries out a specific well defined task.
it is enclosed by
{
------
------
}
advantages:
(1) resusability:
i.e, a function may be used by many other programmers once if you declare a function
that function called by many other programmers.
(2) The length of source programme can be reduce:
every you are writing the same function it is increase the source progrmme code
the code of the programme will be increase so for that you can write a function and you can
save the function in one of the file.so you just call the function name it reduces the lenght of
the source programme.
so first you want to give the name suppose if you want to call any person
how you will call? with the help of his name you just calling that person by announcing his
name.
if you want to call a function it should be first declared and define before calling.