Thursday, April 30, 2009

NextReports - Stored Procedure Call

From version 2.2 of NextReports, there is the possibility to create a report from a stored procedure. To accomplish this, there is a syntax which must be used inside the query editor :
call <schema_name>.<procedure_name><(${P1}, ... , ${Pn}, ?)
where ${P1}, … , ${Pn} are procedure IN parameters. These can also be parameters defined for the query and will appear at runtime. The ‘?’ parameter is the cursor output parameter. For Oracle databases this is used. For other databases like MySql and MSSQL , the call must not contain ‘?’ parameter.

Inside this syntax , also the package (for Oracle) or catalog for other databases must be specified (if there are more procedures with the same name in different packages).

call <schema_name>.<package_name>.<procedure_name>(${P1}, ... , ${Pn}, ?)
call <catalog_name>.<schema_name>.<procedure_name>(${P1}, ... , ${Pn})
Not every stored procedure is a candidate for reporting. It can have any number of IN parameters. It must have an OUT parameter of type REF CURSOR (and only one) for Oracle. Must not have any other OUT parameters.

If some procedure parameters are also query parameters, they must be checked as ‘stored procedure parameters’ and a preview value must be set for them. This preview value must be used inside the procedure business to exit as fast as possible, making the column finding process as fast as possible.

The user can drag and drop a procedure from the explorer panel to the query editor panel. If the procedure is not a candidate for reporting a message will notify the user. If it is a candidate, the general syntax shown previously will be automatically written to the editor. The user will have to define the parameters if any.

The user can see in the explorer tree all the stored procedures. There is an action on Procedures node which will validate which procedures are candidates for reporting. This process will mark the candidates with another icon.