oracle stored procedure (with parameters stored procedure)

 
  
Stored procedure with parameters 

Example: up 100 for the specified employee salary of $ pay before printing and after rising up 

if the band parameters, input parameters specify output parameters or 



Create  or  Replace  Procedure raisesalary (ENO in Number ) 

AS 

 - - the definition of a variable that holds the paycheck up front, sal reference type in the type of emp as psal 

 psal emp.sal % of the type; 

the begin 

 - - get paid employees rose before 

 the SELECT sal INTO psal from emp the WHERE empno = ENO; 

 - - up to the employee 100 

 Update EMP SET SAL = SAL + 100  WHERE EMPNO = ENO; 

 

 -- or you need to commit? 

 - - Note: The procedure is generally not stored or stored function and commit ROLLBACK 

 

 - - before printing and after a raise up 

 DBMS_OUTPUT.PUT_LINE ( ' up front: ' || PSAL || ' up after: ' || (PSAL + 100 )); 

End ; 

/ 



ships then commit call a stored procedure or function when it can guarantee all execution is carried out in the same things 

as: 

the begin 

    raisesalary ( 7839 ); 

    raisesalary ( 7566 ); 

    commit ; 

End ; 

/
 
  

Generally not stored during commit or ROLLBACK, but then after a commit or rollback call a stored procedure, this procedure can be encapsulated in a stored transaction.

 

If it is a command window to use exec stored procedure name, give chestnuts:

1. If it is a command window to use exec stored procedure name, give chestnuts:

EXEC   procedure   ; --procedure是存储过程名

 2. If a PL / SQL window to begin using the stored procedure name end; For chestnuts:

begin

   procedure ; --procedure是存储过程名
end ;

 3. If the program is invoked with a call to the stored procedure name, give chestnuts:

hibernateDao.excuteSqlUpdate ( "{Call proc_stuInfo ()}"); // stored procedure proc_stuInfo

 

Guess you like

Origin www.cnblogs.com/wangchuanfu/p/10960550.html