Wednesday, December 12, 2007

AS/400 Stored Procedures & SYSPROCS

Need to call an RPG program Stored Procedure? You can determine the parameter information required by the JDBC CallableStatement by using the following SQL -
select substr(A.SPECIFIC_SCHEMA,1,10) AS "LIB",                    
       substr(A.SPECIFIC_NAME,1,12) AS "PROC",                     
              ORDINAL_POSITION AS "POS",                           
              PARAMETER_MODE AS "MODE",                            
       substr(PARAMETER_NAME,1,11) AS "PARMNAME",                  
       substr(DATA_TYPE,1,12) AS "TYPE",                           
              NUMERIC_PRECISION AS "PRECISION",                    
              NUMERIC_SCALE AS "SCALE"                             
from qsys2/sysprocs A join qsys2/sysparms B on A.SPECIFIC_SCHEMA = 
B.SPECIFIC_SCHEMA and A.SPECIFIC_NAME = B.SPECIFIC_NAME            
where A.SPECSCHEMA = 'MYLIB'
Be sure to modify the value of MYLIB in the statement.