...
This behavior can be controlled by adding the queryset attribute emptyStringForEmptyResultSet with a value of false to the queryset in the configuration.xml file or by adding the property dbconnector.queryset.emptyStringForEmptyResultSet=false to the dbconnector.properties file.
Post/Put to the Database Connector from a Business Rule
The Database Connector supports URL parameters and JSON payload in POST/PUT requests. You can use http.post() and http.put() statements in a Live Forms business rule to send data to the frevvo Database Connector to insert/update records in your external database.
Use the http.post method to INSERT records into your database and use the http.put method to update existing records.
Let’s take a look at an example to explain this.
Create a form from the Database Connector schema (productDetails) to insert a record to the products table in an external database named classicmodels. We have added a Trigger control to make testing the rules easier. The MySQL classicmodels database has a table named products. When we execute the rule in our frevvo form, we want to insert a record to this database table.
Here is an image of the form:
This query is included in the configuration.xml.
Code Block |
---|
</query>
<query name="productDetails" autocreate="true">
<retrieve>
<!--maps to HTTP GET -->
<statement> SELECT * from Products order by productName </statement>
</retrieve>
<create>
<statement>INSERT into Products (productCode,productName,productLine,productScale,productVendor,productDescription,quantityInStock,buyPrice,MSRP)
VALUES ('{productCode}','{productName}','{productLine}','{productScale}','{productVendor}','{productDescription}',{quantityInStock},{buyPrice},{MSRP})</statement>
</create>
</query>
|
Stored Procedures
You can also execute stored procedures via the database connector. Here is an example of a mySql stored procedure.
...