You can use JDBC escape syntax from any JDBC application, including Interactive SQL. This escape syntax allows you to call stored procedures regardless of the database management system you are using. The general form for the escape syntax is
{{ keyword parameters }}
In Interactive SQL, the braces must be doubled. There must not be a space between successive braces: "{{" is acceptable, but "{ {" is not. As well, you cannot use newline characters in the statement. The escape syntax cannot be used in stored procedures because they are not executed by Interactive SQL.
You can use the escape syntax to access a library of functions implemented by the JDBC driver that includes number, string, time, date, and system functions.
For example, to obtain the name of the current user in a database management system-neutral way, you would execute the following:
SELECT {{ FN USER() }} |
The functions that are available depend on the JDBC driver that you are using. The following tables list the functions that are supported by the iAnywhere JDBC driver and by the jConnect driver.
Numeric functions | String functions | System functions | Time/date functions |
---|---|---|---|
ABS | ASCII | IFNULL | CURDATE |
ACOS | CHAR | USERNAME | CURTIME |
ASIN | CONCAT | DAYNAME | |
ATAN | DIFFERENCE | DAYOFMONTH | |
ATAN2 | INSERT | DAYOFWEEK | |
CEILING | LCASE | DAYOFYEAR | |
COS | LEFT | HOUR | |
COT | LENGTH | MINUTE | |
DEGREES | LOCATE | MONTH | |
EXP | LOCATE_2 | MONTHNAME | |
FLOOR | LTRIM | NOW | |
LOG | REPEAT | QUARTER | |
LOG10 | RIGHT | SECOND | |
MOD | RTRIM | WEEK | |
PI | SOUNDEX | YEAR | |
POWER | SPACE | ||
RADIANS | SUBSTRING | ||
RAND | UCASE | ||
ROUND | |||
SIGN | |||
SIN | |||
SQRT | |||
TAN | |||
TRUNCATE |
Numeric functions | String functions | System functions | Time/date functions |
---|---|---|---|
ABS | ASCII | DATABASE | CURDATE |
ACOS | CHAR | IFNULL | CURTIME |
ASIN | CONCAT | USER | DAYNAME |
ATAN | DIFFERENCE | CONVERT | DAYOFMONTH |
ATAN2 | LCASE | DAYOFWEEK | |
CEILING | LENGTH | HOUR | |
COS | REPEAT | MINUTE | |
COT | RIGHT | MONTH | |
DEGREES | SOUNDEX | MONTHNAME | |
EXP | SPACE | NOW | |
FLOOR | SUBSTRING | QUARTER | |
LOG | UCASE | SECOND | |
LOG10 | TIMESTAMPADD | ||
PI | TIMESTAMPDIFF | ||
POWER | YEAR | ||
RADIANS | |||
RAND | |||
ROUND | |||
SIGN | |||
SIN | |||
SQRT | |||
TAN |
A statement using the escape syntax should work in SQL Anywhere, Adaptive Server Enterprise, Oracle, SQL Server, or another database management system to which you are connected.
For example, to obtain database properties with the sa_db_info procedure using SQL escape syntax, you would execute the following in Interactive SQL:
{{CALL sa_db_info( 0 ) }} |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |