ASA Programming Guide
JDBC Programming
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 braces must be doubled. This doubling is specific to Interactive SQL. 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 type 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 jConnect, and by the iAnywhere JDBC driver.
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 |
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 |
A statement using the escape syntax should work in Adaptive Server 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 type the following in the SQL Statements pane in Interactive SQL:
{{CALL sa_db_info( 1 ) }}