An expression is a combination of one or more constants, literals, functions, column identifiers and/or variables, separated by operators, that returns a single value.

Expressions can be of several types, including arithmetic, relational, logical (or Boolean), and character string. In some Transact-SQL clauses, a subquery can be used in an expression. A case expression can be used in an expression.

The types of expressions that are used in SAP ASE syntax statements are:

Usage | Definition |
---|---|

expression | Can include constants, literals, functions, column identifiers, variables, or parameters |

logical expression | An expression that returns TRUE, FALSE, or UNKNOWN |

constant expression | An expression that always returns the same value, such as “5+3” or “ABCDE” |

float_expr | Any floating-point expression or an expression that implicitly converts to a floating value |

integer_expr | Any integer expression or an expression that implicitly converts to an integer value |

numeric_expr | Any numeric expression that returns a single value |

char_expr | Any expression that returns a single character-type value |

binary_expression | An expression that returns a single |

**Size of Expressions**

Expressions returning binary or character data can be up to 16384 bytes in length.**Arithmetic and Character Expressions**

The general pattern for arithmetic and character expressions is:**Relational and Logical Expressions**

A logical expression or relational expression returns TRUE, FALSE, or UNKNOWN.**Operator Precedence**

Operators have the following precedence levels, where 1 is the highest level and 6 is the lowest.**Arithmetic Operators**

The SAP ASE server uses the following arithmetic operators:**Bitwise Operators**

The bitwise operators are a Transact-SQL extension for use with integer type data. These operators convert each integer operand into its binary representation, then evaluate the operands column by column. A value of 1 corresponds to true; a value of 0 corresponds to false.**String Concatenation Operator**

You can use both the + and || (double-pipe) string operators to concatenate two or more character or binary expressions.**Comparison Operators**

The SAP ASE server uses these comparison operators:**Nonstandard Operators**

These operators are Transact-SQL extensions.**Using any, all, and in**

Use any, all, and in in your queries to return different results.**Negating and Testing**

not negates the meaning of a keyword or logical expression.**Ranges**

between is the range-start keyword; and is the range-end keyword.**Using Nulls in Expressions**

Use is null or is not null in queries on columns defined to allow null values.**Connecting Expressions**

and connects two expressions and returns results when both are true. or connects two or more conditions and returns results when either of the conditions is true.**Using Parentheses in Expressions**

Parentheses can be used to group the elements in an expression. When “expression” is given as a variable in a syntax statement, a simple expression is assumed. “Logical expression” is specified when only a logical expression is acceptable.**Comparing Character Expressions**

Character constant expressions are treated as varchar. If they are compared with non-varchar variables or column data, the datatype precedence rules are used in the comparison (that is, the datatype with lower precedence is converted to the datatype with higher precedence). If implicit datatype conversion is not supported, you must use the convert function.**Using the Empty String**

The empty string ("") or ('') is interpreted as a single blank in insert or assignment statements on varchar or univarchar data.**Including Quotation Marks in Character Expressions**

There are two ways to specify literal quotes within a char, or varchar entry.**Using the Continuation Character**

To continue a character string to the next line on your screen, enter a backslash (\) before going to the next line.

Created May 28, 2014. Send feedback on this help topic to Technical Publications: pubs@sap.com