Stored procedures can be written in COBOL, PL/1, REXX and Java etc.
Db2 stored procedures are handled by WLM -work Load Manager.
Main uses are reusability and security. How to write stored procedure?
The below code shows of it:
CREATE PROCEDURE UPDATE_SALARY (IN EMPLOYEE_NUM CHAR(6), IN RATE1 DECIMAL(5,2))
WLM ENVIRONMENT SAMP1
COMMIT ON RETURN YES
IF RATE1 <= 0.7
THEN UPDATE EMP
SET SALARY = SALARY * RATE1
WHERE EMPNO= EMPLOYEE_NUM;
ELSE UPDATE EMP
SET SALARY = SALARY * 0.7
WHERE EMPNO = EMPLOYEE_NUM;
There are three parameters passed to SP(stored procedure). IN- Input, OUT-Output INOUT-Input and output.
- SQL stored Procedure – Convert date format (stackoverflow.com)
- Run one store procedure within another store procedure in sql server 2008 (stackoverflow.com)