EasyManua.ls Logo

Sybase Adaptive Server Anywhere - Java Expressions

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Expressions
234
For example, the following statement uses a case expression as the third
clause of a SELECT statement to associate a string with a search-condition.
SELECT id, name,
( CASE
WHEN name=’Tee Shirt’ then ’Sale’
WHEN quantity >= 50 then ’Big Sale’
ELSE ’Regular price’
END ) as Type
FROM "DBA".Product
The NULLIF function provides a way to write some CASE statements in
short form. The syntax for NULLIF is as follows:
NULLIF (
expression-1
,
expression-2
)
NULLIF compares the values of the two expressions. If the first expression
equals the second expression, NULLIF returns NULL. If the first expression
does not equal the second expression, NULLIF returns the first expression.
CASE statement is different from CASE expression
Do not confuse the syntax of the CASE expression with that of the CASE
statement.
$ For information on the CASE statement, see "CASE statement" on
page 412.
Java expressions
The following kinds of Java expressions can be used as SQL expressions:
Java fields Any field of an installed Java class can be invoked
wherever an expression is required. The data type of the expression is
converted from the Java field data type according to the table in "Java
to-SQL-data type conversion" on page 294. Both instance fields and
class fields can be used as expressions.
Java methods Any method of an installed Java class can be invoked
wherever an expression is required. The data type of the expression is
converted from the return type of the Java method according to the table
in "Java to-SQL-data type conversion" on page 294. Both instance fields
and class fields can be used as expressions.
Java objects The NEW operator is an extension to the SQL language
that allows it to better assimilate Java syntax.
NULLIF function
for abbreviated
CASE expressions

Table of Contents

Related product manuals