Generating pureQuery code from stored procedures

If a stored procedure has parameters, you can generate a bean that represents those parameters. If the stored procedure returns result sets, you can generate a bean for each result set. You can also generate code in support of the annotated-method and inline programming styles.

Before you begin

About this task

If you want to use the annotated-method programming style, you can choose to generate the following Java objects:
  • An interface that contains the abstract annotated method for calling the stored procedure.

    If you choose to generate this interface, the workbench also generates an implementation of the interface during a build of the Java project

  • A test class that calls the methods in the implementation and displays the results in the Console view.

If you want to use the inline programming style, you can choose to generate a test class that contains the inline method for calling the stored procedure that the generated beans are based on. When you run the class, the results are displayed in the Console view.

Procedure

To generate pureQuery code from a stored procedure:

  1. In the Data Source Explorer, right-click the stored procedure that you want and select Data Access Development > Generate pureQuery Code. The Generate pureQuery Code from a Stored Procedure wizard opens.
  2. Complete the wizard steps. For detailed information about each field, press F1.
  3. Click Finish to generate the files that you specified.

Results

If you did not already add pureQuery support to your Java project, after you click Finish the workbench creates the folder dataAccessFolder in your Java project.

If you are using DB2® for z/OS®, or DB2 for Linux, UNIX, or Windows, this folder contains the files Default.genProps and Default.bindProps. You use these files if you plan to run SQL statements statically from applications that use annotated methods.


Feedback