This shows you the differences between two versions of the page.

Link to this comparison view

sqltag [2016/09/22 02:36] (current)
Line 1: Line 1:
 +Sql tag is a command tag but can only be inside a [[datasetTag|dataset tag]]. It is used to declare the sql statement to be used by the [[datasetTag|dataset tag]] to retrieve the data from jdbc data source.
 +The syntax is:
 +    <sql db="​myDB">​select * from products where prod_id = ?</​sql>​
 +Notice the use of question mark ? for runtime parameter.
 +you may only have one sql tag for each [[datasetTag|dataset tag]].
 +Use **getData(...)** in [[mScriptFunc|mScript functions]] to retrieve data row/field from the dataset.
 +Please be aware that all columns retrieved in the sql statement must be in string data type to ensure that the original data formats are preserved as they are retrieved into dataset.
 +There are several ways to make sure columns are retrieved in string data type:
 +  * use Excel to change the format for the column to "​Text"​.
 +  * use sql syntax to convert original column data to a string, for example the following will convert a date column column1 to a string during retrieval:
 +     ​FORMAT(column1,​ "​mm/​dd/​yyyy"​) as newColumn
QR Code
QR Code sqltag (generated for current page)