SQL - Built-in Database Function¶
Purpose¶
Executes a SQL statement and returns the result.
Syntax¶
SQL(str)
Arguments¶
| Argument | Required | Description |
|---|---|---|
str |
Yes | A valid SQL expression. |
Returns¶
String
See also¶
IsDummyZeroDate, Next, Previous, Sum
Example¶
// returns the sum of the purchases of all customers in a state
return SQL("SELECT SUM([customer].[purchases]) FROM [dbo].[Customer] WHERE [customer].[state]='" + {Customer.State} + "'")
// Get the value of the column description from the codemast table with the filter on type (codetype table) and code from the orderheader table
return SQL("SELECT [Description] FROM [CodeMast] WHERE [Type]='SHIPPING' AND [Code]='" + {Orderheader.Ship_Via} + "'")
Notes¶
- Not all database connections support this function. Function is not supported for the DataFlex embedded database, Runtime data-source, ODBC SQL Statement and Stored procedures.
- The SQL statement is passed to the server 'as is' and no validation takes place.
- The current connection is used to pass the SQL statement to the server. Use the SQL login credentials to limit what can be done via the SQL() function, i.e. disable 'drop table' statements.
- The function can only return 1 value.