| TechTip: Speed Up SQL Procedures with Service Program Support |
|
|
|
| Tips & Techniques - SQL | |||||
| Written by Kent Milligan | |||||
| Thursday, 07 August 2008 19:00 | |||||
|
With a recent V6R1 PTF, SQL stored procedures can now benefit from the improved performance offered by IBM i service program objects.
The usage of SQL stored procedures by IBM i applications and programs continues to rise. For quite awhile, applications have had the ability to leverage the performance benefits offered by IBM i service program objects.
With a recent V6R1 PTF, SQL stored procedures can now benefit from the improved performance offered by IBM i service program objects. When an SQL stored procedure is created, DB2 for i generates and creates an ILE C program object to implement the business logic specified by the programmer. For example, when the following procedure is created, it will result in DB2 generating an ILE C program object (*PGM) named ADD_PGM in the QGPL library. Whenever an application invokes the ADD_PGM, DB2 will transparently call the generated C program object.
CREATE PROCEDURE QGPL/ADD_PGM (IN p1 INT, IN n INT, OUT o1 INT) LANGUAGE SQL BEGIN
DECLARE v1 INT; SET v1=ABSVAL(n); SET o1= p1+v1;
END;
CREATE PROCEDURE QGPL/ADD_SRVPGM (IN p1 INT, IN n INT, OUT o1 INT) LANGUAGE SQL PROGRAM TYPE SUB BEGIN
DECLARE v1 INT; SET v1=ABSVAL(n); SET o1= p1+v1;
END;
You can find more information on the CREATE PROCEDURE statement syntax in the DB2 for i SQL Reference. | |||||
View all articles by this author
|
|||||
| Last Updated on Tuesday, 19 May 2009 10:35 |






You must be logged in to view or make comments on this article.