Section | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Code Block |
---|
<query name="products" autocreate="true" autodelete="true" deleteKey="id"> <retrieve> <statement> <!-- Maps to the HTTP GET method --> SELECT * FROM products WHERE orderId='{orderId}' </statement> </retrieve> <create> <statement> INSERT INTO products (orderId, productName, quantity,price) VALUES ({orderId}, '{productName}', '{quantity}', {price}) </statement> </create> <update> <statement> UPDATE products SET productName = '{productName}', quantity = {quantity}, price = {price} WHERE id = {id} </statement> </update> <delete> <statement> DELETE from products where id={id} </statement> </delete> </query> |
- Note that the id column of this products table is a Primary Key/Unique column and an automatically incrementing number is assigned as value to this column (on the database side) when inserting a new record in Products table.
- Notice the autocreate and autodelete attributes of this query. Please see Auto Create Rows above.
- This query has all the CREATE, RETRIEVE, UPDATE, and DELETE statements declared in it.
- To create the schema, browse the DB connector query URL with /schema appended to it. For example: http://localhost:8082/database/BIRT/products/schema?orderId=10000
After creating the form fields using this schema, configure the Doc Action -> Doc URI to:
- Read URL: http://localhost:8082/database/BIRT/products?orderId=\{orderId} with method: GET
Write URL: http://localhost:8082/database/BIRT/products with method: PUT
Info See this section for an explanation of how HTML statements (GET, PUT, etc.) translate to SQL statements (RETRIEVE, UPDATE, etc.)
- Test the form. Enter a valid orderId, and notice that the form table will automatically expand and display all the order items retrieved by the SELECT statement.
- Add a row and enter some data.
- Edit another row.
- Delete a different row.
- Submit the form. The database connector will
- Execute the INSERT statement for any form table row that was added.
- Execute the UPDATE statement for any form table row that was changed.
- Execute the DELETE statement for any form table row that was deleted.
Info |
---|
What is happening "behind the scenes"? When you use the Doc URI approach to read/add/update/delete rows, the controls in your form are bound to the schema (data source) from which they were created. When the form is submitted, frevvo creates an XML document which conforms to that schema. This XML document has all the values entered in those schema controls. When the form is submitted, this XML document is sent to the DB connector. The DB connector can get the control values directly from this document and use them while executing the SQL query. |
Dates and Timestamps
...
The timeToIdle parameter specifies the number of seconds before retrieving a fresh resultset database to be cached again.. This example will refresh the cache every 300 seconds. If you set this value to 0, caching will never expire.
Send User ID in "Use Mode"
If you are looking for a simple way to communicate information about the logged in user when DOC URI's are invoked, subject parameters are now included in http headers whenever is configured to make a call to the database connector on behalf of a given user. has been changed so that a request header called _frevvo.subject.id will be populated in the following cases:
- http calls from rules
- DOC URI calls
- doc/form action posts
The database connector has been enhanced to inspect http headers for resolving query parameters. Any URL parameter that begins with "_frevvo" will be ignored. Only user id is supported at this time.
Note |
---|
If a database connector is going to be configured against a database with sensitive data, you must secure it so that the database war only accepts requests from . Enabling this type of security is is typically done by a System Administrator. |
In the database connector, these parameters can be referenced in the sql configuration file just like any other parameters:
...
Disabling QuerySets/Queries
...
Add the enabled= attribute with a value of false to the <querySet/> or individual <query> elements in the configuration.xml file to completely disable it. The first example disables the queryset named BIRT and the second example disables the allCustomer query.
Code Block title This example disables the querySet named BIRT <dbconnector> <queryset name="BIRT" enabled="false" ...>
Code Block language sql title This example disables the querynamed allCustomers <queryset name="BIRT"> <query name="allCustomers" autocreate="true" enabled="false" > <retrieve> <!-- maps to HTTP GET --> <statement> SELECT customerNumber,customerName from Customers order by customerName </statement> </retrieve> </query>
The same can be done by adding the enabled property with a value of false as shown below to the dbconnector.properties in the standalone or tomcat bundles.
Code Block dbconnector.queryset@<queryset name>.enabled=false
This property disables all querysets. Add it to the dbconnector.properties(standalone bundle) or frevvo-config.properties (tomcat bundle).
Code Block dbconnector.queryset.enabled=false
...