Loading multiple rows with SQL Load
SQL Load is an eFORMz procedure to load one or more rows of data from one or more columns of a relational database. Use the eFORMz function Table Lookup to load a single value from a row of a table. Table Lookup is simpler and more efficient for single-value queries.
Complete the following steps to set up an SQL Load procedure. This example lists the invoice date, invoice amount, and invoice status for one customer. You must have a variable set to the number identifying the customer. That value typically comes from a data file.
- Open your project in the eFORMz Composer.
- Create a database connection.
- This example sets a variable, CustNum, to 12345. This is the customer number whose invoices we want to list.
- Create a variable for each column you want to include in the result set: InvDate, InvAmt, InvState. To create a variable, right click Variable in the Project window > Add variable > By position. Name the variable, and click OK.
- Right click the form > Add Pre-condition Procedure > SQL Load. If you have a condition on the form, use Add Post-condition Procedure instead. A post-condition procedure has additional performance costs, so avoid it when possible.
- Name the procedure. In the Use variable field select N/A. Click OK.
- In the SQL Load window, select which database connection to use.
- In Parameters, click Add. Select the variable that contains the customer number.
- Type your SQL statement into the SQL statement area. Type a question mark (?) where the customer number goes. If you have multiple parameters, they are evaluated in the order they are listed in the Parameters area. For example, the following query requires the first parameter in Parameters to be the customer number, and the second to be the region:
select InvDate, InvAmt, InvState from invoices where CustNum = ? and Region = ?
- Click Add in the Columns area. Add the variables that you created in Step 4 in the order that your query returns them.
- Click OK.
- If your database connection is active, the query returns the result set as an array: