Content-type: text/html Sql Tag

Home
WebGroove is no longer supported. These docs are reference only.


Sql Tag
Execute a SQL statement within an Agent script. If a detail block is specified, it will be processed once for each row retrieved. Otherwise, only the first row (if any) will be retrieved.

Examples
<sql detail=show_user result=user dbcon=user>
select * from user
order by last_name, first_name
</sql>

<sql result=cust>
select * from customer
where customer_id = {cgi:id}
</sql>


Syntax
This is always a single tag.

Attributes
detail=Specifies a predefined detail block to process for each row retrieved.
result=Store the resulting data in the named Agent hash. This defaults to col.
dbcon=Use this named database connection. If the named connection isn't already open, this will open it. It will remain open for future use until the script is complete.
connectSpecifies a database connect string to use instead of the system connect string.
pgsize=The number of records in a display page, if query paging is to be used. By default, paging is off.


Notes
Unless a dbcon is specified, a new database connection is opened, the query is executed, and the connection closed. So, if you're doing many queries in the same script, it can noticeable improve performance to use the same named connection for all of them. Don't use the same connection on nested queries, however, where one sql statement is executed within the detail block of another.

If a detail block is specified, it must have been defined earlier in the script with the detail tag.

More
Database Connect String
Query Paging
Reusing Database Connections

See Also
Detail Tag

Up To
Agent Tags
Complete Tag Reference


WebGroove® is a registered trademark of Creativision Publishing Corporation