0% found this document useful (0 votes)
49 views1 page

NOW " ( ) " - NUMBER " ( ) " - PI " ( ) " - TODAY " ( ) " - Traceback " ( ) "

This section discusses built-in scalar functions in SQL Anywhere 9, which operate on individual rows rather than aggregates of rows. There are approximately 175 built-in functions, though some are redundant. The top 15 most useful functions are presented alphabetically, including CAST, COALESCE, LEFT, LENGTH, LOCATE, LOWER, LTRIM, REPEAT, REPLACE, RIGHT, RTRIM, STRING, and SUBSTR.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views1 page

NOW " ( ) " - NUMBER " ( ) " - PI " ( ) " - TODAY " ( ) " - Traceback " ( ) "

This section discusses built-in scalar functions in SQL Anywhere 9, which operate on individual rows rather than aggregates of rows. There are approximately 175 built-in functions, though some are redundant. The top 15 most useful functions are presented alphabetically, including CAST, COALESCE, LEFT, LENGTH, LOCATE, LOWER, LTRIM, REPEAT, REPLACE, RIGHT, RTRIM, STRING, and SUBSTR.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

108 Chapter 3: Selecting

| NOW "( * )"


| NUMBER "( * )"
| PI "( * )"
| TODAY "( * )"
| TRACEBACK "( * )"
The first three categories are called scalar functions because they are executed
once per row when they appear in a select list, as opposed to aggregate func-
tions, which operate on multiple rows.
This section discusses the scalar built-in functions, both ordinary and spe-
cial, with the exception of NUMBER(*), which is covered in Section 3.20.
Aggregate functions are discussed in Section 3.14, and user-defined functions
are covered in Section 8.10.
There are approximately 175 different built-in functions in SQL Anywhere
9; the number varies depending on whether you count functions like REPEAT()
and REPLICATE() as being different (they arent). One book cant do them all
justice, and frankly, some of them arent worth the effort; how much can you
say about NOW(*) other than that it returns CURRENT TIMESTAMP?
Its not fair, however, to make fun of legacy artifacts like TODAY(*) and
weird Transact-SQL abominations like CONVERT(). One of SQL Anywheres
strengths lies in its rich variety of built-in functions, all explained quite well in
the SQL Anywhere Help file. This section presents some of the most useful,
starting with (in the authors opinion) the top 15 in alphabetic order:
Table 3-1. Top 15 built-in scalar functions
Function Description
CAST ( p AS q ) Returns p after conversion to data type q.
COALESCE ( p, q, ... ) Returns the first non-NULL parameter.
LEFT ( p, q ) Returns the leftmost q characters of string p.
LENGTH ( p ) Returns the current length of string p.
LOCATE ( p, q [ , r ] ) Returns the first position of string q in string p, starting
the search at r if it is specified.
LOWER ( p ) Returns string p converted to lowercase.
LTRIM ( p ) Returns string p with leading spaces removed.
REPEAT ( p, q ) Returns q copies of string p concatenated together.
REPLACE ( p, q, r ) Returns string p with all occurrences of string q replaced
with string r.
RIGHT ( p, q ) Returns the rightmost q characters of string p.
RTRIM ( p ) Returns string p with trailing spaces removed.
STRING ( p, ... ) Returns a string consisting of each parameter converted
to a string and concatenated together.
SUBSTR ( p, q [ , r ] ) Returns the substring of p starting at q for length r, or
until the end of p if r is omitted.

You might also like