398 users using DBSP now!
home -> documentation -> Language reference ->QRYEXEC tag


Description

This element allows you to execute SQL sentences that does not have a result set. This is the case of inserts, updates, deletes or some kinds of stored procedures.

Syntax

<#QRYEXEC ALIAS="alias" QUERYID="Id" [DOC="document"] [MULTIVALUEPARAMS="param1, param2,.. paramN"] [MULTIVALUERANGE="a..b"] [NOMASTERSOURCE]>

ALIAS This property defines the in which database in the sentence will be executed. The database is referenced by the alias name previously configured with the DBSP Configuration application.
QUERYID Define in Id the object identification number that was assigned by the DBSP Builder to the SQL sentence that you want to execute.
DOC Define in document the page that will be retreived after the execution of the SQL sentence. If this property is not defined, the sentence will be executed as soon as it be interpreted.
MULTIVALUEPARAMS This property is used for multiple execution of SQL sentences. This feature could be used in order to insert or delete multiple records in a single page. Define a comma separated list of the fields that will match this criteria, for example: FIRSTNAME, LASTNAME, AGE.
MULTIVALUERANGE This property is used for multiple execution of SQL sentences. Define here for what range, the SQL sentence will be executed. For example, a valid value for this property could be 1..3. In this case (and using the fields defined in the previous property), the SQL sentence will be executed 3 times. In the first query execution, the values contained in the controls FIRSTNAME1, LASTNAME1, AGE1 will be used in the query. In the second execution the values contained in the controls FIRSTNAME2, LASTNAME2, AGE2 will be used. Finally, in the third execution, the values FIRSTNAME3, LASTNAME3, AGE3 will be used.
NOMASTERSOURCE If the QRYEXEC tag is contained inside a DATASET tag, the DATASET tag is ignored and no Master-Detail relationship is created.

Applications

Use the QRYEXEC tag when you want to modify any information of a database by executing an insert, update or delete statement.

The QRYEXEC element could be used in two different ways:

Mode A: Executing immediately

If you do not define the DOC property, the query will be executed as soon as it became interpreted. This is useful when we need to execute multiple statements in certain page.

<#QRYEXEC ALIAS="TEST" QUERYID="1"> <!-- Executed immediatly >
<#QRYEXEC ALIAS="TEST" QUERYID="7"> <!-- Executed immediatly >
<#QRYEXEC ALIAS="TEST" QUERYID="8"> <!-- Executed immediatly >
<#REDIRECT DOC="page2.dbsp">

Mode B: Executing as an URL

In this mode, you set the property DOC to a certain document that you want to retrieve after the execution of the sentence. Here, the element will not execute the sentence at the moment of the interpretation. Instead, it will replace the element with an URL. Just when this URL is requested, then sentence is executed. This is very useful for defining multiple actions in a single page (for example: adding, updating and deleting information from a catalog, depending on the user selection).

<!-- This won't be immediatly executed. Instead, the QRYEXEC will be replaced by an URL >
<form name="TheForm" method="post" action="<#QRYEXEC ALIAS=TEST QUERYID=14 DOC=Insert.dbsp/>">

Examples

Example 1. Insert data into a table

The following example shows how to create a user catalog where you can add information to the catalog.

Source code
Test example



Example 2. Update a record

The following example shows how update the user account that has been created in the previous example.

Source code
Test example



Example 3. Delete a record

The following example shows you how delete a user account.

Source code
Test example



Example 4. A simple insert and delete.

This example shows you how to insert and delete records from a table.

Source code
Test example



Example 5. Inserting multiple records.

This example shows you how to insert multiple records into a table.

Source code
Test example