Inserting Multiple Database Records

Inserting Multiple Database Records

Learn how to insert multiple database records

In this tutorial you will learn how easy it is to insert multiple database records using DMXzone App Connect.

Step by Step

First, let's create a new server action. Open the server connect panel and click the add new server action button (1). We call it "multi insert" (2). Add a database connection step  (3-5).

Right click the database connection when you're done (1). Add database multi insert (2-3).

Select the database insert step and setup its options (1-3).

All you need to do is select and add the table you want to insert data into (1-3).

Add the columns you want to insert data into (1-2). And click OK (3).

Save your server action and open the app connect panel (1-2).

Add app connect to your page.

For multi insert you have many options to select how many records to insert. For example, you can enter the exact number of records to be inserted or you can use an input, select menu or an URL variable to allow users to select the number. In this tutorial we will show you how to do this using a dropdown. Click on your page where you'd like to insert the dropdown (1). Click: insert, form, select (2-4).

Add some values to it (1-2). Click ok, when you're done (3).

Now, let's add the multi insert form.

Click on your page where you'd like to insert it (1). Click the add new component button (2). Under bootstrap 3, select form generator (3-4).

Select the multi insert server action from the dropdown (1-2). The multi record checkbox is automatically checked when a multi insert or update record action is detected (3).

Setup the form properties and click ok when you are done (1-3).

The multi insert record form, has been generated. Now let's setup the expression, i.e. how many records to be inserted. 

Expand the form in the app connect tree (1). Select the repeat children region (2). Here, you can manually enter the exact number of records to be inserted or you can select a dynamic value for it. We'd like to use the value selected in the drop-down so we click the dynamic data picker button (3). Under select, we click "value" (4). The values returned by the HTML form fields are always strings. We need this value to be a number. So let's convert it to number using the app connect formatter. Click the formatter button (4).

Right click the expression (1). Under conversion, select "to number" (2-3). Click select in order to apply the expression (4-5). Now you can add some event on success insert like, redirect, notification, form reset, etc. We've already shown how to do this in our previous tutorials, so we won't show this now. 

And we're done! Let's preview the results.

Select the number of records to be inserted using the drop-down on the page. You can see that the number of form fields changes depending on the selected value. Then fill the form fields and click the submit button. That's how easy it is to insert multiple database records using DMXzone App Connect.

Extensions Covered

Comments

Be the first to write a comment

You must me logged in to write a comment.