<CSP:SQLQUERY>
Synopsis
<CSP:SQLQUERY>...</CSP:SQLQUERY>
Attributes
General Attributes
Attribute | Description | Value |
---|---|---|
DATASOURCE | This specifies the name of an external data source to be used for this query. | A string. |
MODE | Runtime mode of the query. | “LOGICAL”, “ODBC”, “DISPLAY”, or “SYSTEM”. |
NAME | Name of local variable used to refer to the %ResultSet Opens in a new tabobject created for this query. | A string. |
P1 | Value of the first query parameter. | A string. |
P2 | Value of the second query parameter. | A string. |
P3 | Value of the third query parameter. | A string. |
P4 | Value of the fourth query parameter. | A string. |
PASSWORD | Optional password for the external data source. | A string. |
USERNAME | Optional username for the external data source. | A string. |
Description
The <CSP:SQLQUERY> tag creates a %ResultSetOpens in a new tab object based on a dynamic query defined by an SQL statement. The query may contain parameters (values substituted at runtime) within its WHERE clause. These parameters are specified using the ? character. The <CSP:SQLQUERY> tag defines a server-side variable, whose name is specified by the tag's name attribute, that refers to a %ResultSetOpens in a new tab object. The %ResultSetOpens in a new tab object is automatically prepared and executed (by calling its Execute method using the parameter values given by the various Pn attributes of the tag) and is ready for use within the page.
This tag is identical to the <SCRIPT LANGUAGE=SQL> tag except that it may be used to redirect the query to an external database using the Caché SQL Gateway.
The following example creates an unordered list by running a query:
<csp:SQLQUERY NAME='query' P1='A'>
SELECT ID,Name FROM IscPerson WHERE Name %STARTSWITH ? Order By Name
</csp:SQLQUERY>
<ul>
<csp:WHILE CONDITION="query.Next()">
<li>#(query.Get("Name"))#
</csp:WHILE>
</ul>
Specifying an External Database
When the optional DATASOURCE attribute is specified, it redirects the query to an external database using the Caché Relational Gateway.
<CSP:SQLQUERY DATASOURCE>...</CSP:SQLQUERY>