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 }
The set of keywords includes the following:
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 current date in a database management system-neutral way, you would execute the following:
SELECT { FN CURDATE() }
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 SQL Anywhere JDBC driver and by the jConnect driver.
Numeric functions | String functions | System functions | Time/date functions |
---|---|---|---|
ABS | ASCII | DATABASE | CURDATE |
ACOS | BIT_LENGTH | IFNULL | CURRENT_DATE |
ASIN | CHAR | USER | CURRENT_TIME |
ATAN | CHAR_LENGTH | CURRENT_TIMESTAMP | |
ATAN2 | CHARACTER_LENGTH | CURTIME | |
CEILING | CONCAT | DAYNAME | |
COS | DIFFERENCE | DAYOFMONTH | |
COT | INSERT | DAYOFWEEK | |
DEGREES | LCASE | DAYOFYEAR | |
EXP | LEFT | EXTRACT | |
FLOOR | LENGTH | HOUR | |
LOG | LOCATE | MINUTE | |
LOG10 | LTRIM | MONTH | |
MOD | OCTET_LENGTH | MONTHNAME | |
PI | POSITION | NOW | |
POWER | REPEAT | QUARTER | |
RADIANS | REPLACE | SECOND | |
RAND | RIGHT | WEEK | |
ROUND | RTRIM | YEAR | |
SIGN | SOUNDEX | ||
SIN | SPACE | ||
SQRT | SUBSTRING | ||
TAN | UCASE | ||
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 SAP Sybase IQ, Adaptive Server Enterprise, Oracle, SQL Server, or another database management system to which you are connected.
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 parsed by Interactive SQL.
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 ) }}