Stored Procedure

  • Last update:September 22, 2025
  • Overview

    A stored procedure is a set of SQL statements stored in the database. FineReport allows you to call stored procedures directly to obtain the table generated after the SQL statements are executed.

    The following section takes an MySQL database as an example to demonstrate how to create a template dataset from the stored procedure.

    iconNote: 

    1. When executing a stored procedure to obtain the result dataset, the system only supports statements starting with {CALL and {?=CALL; statements starting with EXEC are not supported.

    2. If you want to apply the dataset function tablename.select() to the dataset obtained from the stored procedure, you should write the function in the format of Stored procedure name_Result dataset name.select(), for example, Datas_Table.select(Tm_QY_Ic_Sum). Otherwise, the call will not succeed. When a stored procedure contains multiple result sets, you need to check which result set contains the required field and use the name of that result set in the statement.

    Defining the Dataset

    1. Click the icon and Stored Procedure to create a dataset, as shown in the following figure.

     2-1.jpg

    2. Select a database. The stored procedures in the database are displayed in the left box. Double-click the stored procedure, as shown in the following figure.

     2-2.jpg

    iconNote: 
    MySQL, IBM Db2, Oracle, and SQL Server databases can automatically retrieve parameters and their default values, while Microsoft Access, HSQL, and Sybase databases require you to manually add parameters and their values.

    In MySQL, query results of stored procedures do not use column aliases by default. That is, in statements like SELECT XXX AS Alias FROM ..., the original column name XXX is used by default in the result set, rather than the alias specified after AS.

    To display the column aliases, you need to suffix ?useOldAliasMetadataBehavior=true to the database connection URL. For example, jdbc:mysql://env.finedevelop.com:55703/testskp?useOldAliasMetadataBehavior=true.

    3. Click the icon to preview the result dataset of the stored procedure.

     2-3.gif

    4. Click OK, and the dataset obtained from the stored procedure is added successfully, as shown in the following figure.

     2.4.jpg

    iconNote: 
    FineReport can only return result sets from stored procedures, not individual parameter values.

    Support for Returning Multiple Result Sets

    If a stored procedure returns multiple result sets, these result sets will be returned in FineReport at the same time, as shown in the following figure.

     3-1.jpg

    Click the icon. You can view the multiple result sets, as shown in the following figure.

     3-2.jpg

    You can also view these result sets in the created template dataset, as shown in the following figure. 

    3-3.jpg

    Attachment List


    Theme: Data Preparation
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy