데이터베이스/PL/SQL

PL/SQL PL/SQL블록에 함수

왕왕왕왕 2015. 11. 13. 09:35

함수명은 first_function으로 하고 리턴형은 varchar2로한다.

create or replace function first_function return varchar2 as
    begin
    return 'Hello World';
end first_function;
 /

 

 

str이라는 같은형에 변수를만들고

str에 함수를불러와서 텍스트를 넣는다.

 

declare
       str varchar(100) :=null;

 begin
 str := first_function;
 dbms_output.put_line(str);

end;
/