Calling database functions
You can call built-in and user-defined functions (UDFs) through an eFORMz database connection. First, you configure the database connection, then create a variable to pass to the function as a parameter, and then create a variable to pass to the database with the first variable as a parameter. Complete the following steps to call a function on your database server:
Define your database connection
- Start the eFORMz Composer and open your project.
- Click Projects > Properties and go to the Databases tab.
- Click New and define your database connection:
Database connection name The local name to identify the database connection. Driver class The identity of the file that tells Java how to connect. More information is at Supported URL and Driver Classes. URL The connection string for the database. The URL includes the IP address or host name and port to connect to along with properties such as a user ID, password, and default schema. Properties You can add properties to include in the URL here.
- Click Test to test the connection.
- Optional: Click Save to file to save the connection definition in a separate file so you can reuse the connection with other projects.
- Click OK to close the Configure database connection window.
- In the Project Properties window, select the database connection name, and then click Activate.
- Click OK.
Create the variable to pass to the function
You can create variables in several ways. For details, see “Creating an eFORMz Variable” in the Minisoft eFORMz Manual. You can skip this step if your function does not require a parameter.
Create a second variable that passes the previously defined variable as a parameter
- Add a variable to your form by right clicking Variables > Add Variable > By position…
- Type a name for the variable and click OK.
- Right click the variable you just created and click Add Function > SQL Lookup.
- Verify that the Database field has the correct database connection name.
- Select the Constant radio button. In the Constant field, type SELECT followed by the function this way if you created a UDF named fn_MyFunction in the dbo schema:
- Click the Add button in the Parameters area and select the variable that you want to pass to the function.
- Click OK to save your changes. Save your project.
Check that your variables are in order
The variables are processed sequentially in the order they are listed in the Project window. The variable to pass to the function must come before the variable that passes it. You can drag and drop the variable icons to change their order.