Oracle stored procedures, stored functions

- **************************** 
-               stored Procedures 
- **************************** **** 


- stored procedure 
the CREATE  OR  the REPLACE preocedure getName (ENO Number , the uname OUT VARCHAR )
 the IS 

 S VARCHAR ( 100 ); 

the BEGIN 

        the SELECT the uname the INTO S the FROM UserInfo the WHERE ID = ENO; 
        the uname: = S; 

the END ; 


- call 
DECLARE 
SVARCHAR ( 100 );
 the BEGIN 
getName ( . 1 , S) 
dbms_outpt.put_line (S) 

the END ; 


- **************************** ******************** 
-               memory function 
- ************************ ********************************************************** 

- storage function 
the CREATE  OR  the REPLACE  the fUNCTION Fun (ENO Number )   the RETURN  Number 
the IS 
   S Number ( 10 ); 

the BEGIN 

the SELECT  COUNT ( . 1 ) the INTO S the FROM userinfo WHERE id = eno;
RETURN s;
END;



-- 调用
SELECT fun(1) FROM DUAL;

 

Guess you like

Origin www.cnblogs.com/wuzaipei/p/12507123.html