Until this moment, we have only been retrieving information from the database. But now is time to make some modifications to the data according to our requirements. This is done with the QRYEXEC tag.
The QRYEXEC tag
The QRYEXEC tag is used to insert, update or delete records. It could be used also for executing stored procedures that modify any database information.
You should use the QRYEXEC tag when the SQL sentence does not return a result set. Otherwise, if you are interested in using some information returned after the execution of the query, you must use the DATASET tag instead.
QRYEXEC Tag modes
There are two possible modes using the QRYEXEC tag:
Mode A: Immediate execution
<#QRYEXEC ALIAS="DEMO" QUERYID="12"/>
This query is executed immediately after being interpreted.
In this case, the QRYEXEC tag is substituted by an URL. When this URL became requested, the assigned query will be executed and the defined document will be sent as the response. You could use this mode, in an HTML anchor or in the action property of a form. Check both modes in the examples section.
<!-- Notice that the action property of the form contains a QRYEXEC Tag with a DOC property set to this file. This means, that the query 14 will be executed and then this page will be retreived again. -->
SQL Sentence: ID=13
SELECT * FROM CONTACTS
SQL Sentence: ID=14
INSERT INTO CONTACTS (USERNAME, EMAIL)
VALUES
('<#CONTACTNAME>','<#EMAIL>')
When you use a multiple execution statement, the first field in the MULTIVALUEPARAMS list must not be null (in this case, the NAME field). Otherwise, the entire row is ignored and the statement does not execute for this particular row.
<!-- Notice that the action property of the form contains a QRYEXEC Tag with a DOC property set to this file. This means, that the query 14 will be executed for each row and then this page will be retreived again. -->
SQL Sentence: ID=13
SELECT * FROM CONTACTS
SQL Sentence: ID=14
INSERT INTO CONTACTS (USERNAME, EMAIL)
VALUES
('<#CONTACTNAME>','<#EMAIL>')