Dumies collection

Page 177

Chapter 7: Specifying Values The default trim character is the blank, so the following syntax also is legal: TRIM (BOTH FROM ‘ treat ‘) This syntax gives you the same result as the third example in the table — ‘treat’.

TRANSLATE and CONVERT The TRANSLATE and CONVERT functions take a source string in one character set and transform the original string into a string in another character set. Examples may be English to Kanji or Hebrew to French. The conversion functions that specify these transformations are implementation-specific. Consult the documentation of your implementation for details. If translating from one language to another was as easy as invoking an SQL TRANSLATE function, that would be great. Unfortunately, the task is not that easy. All TRANSLATE does is translate a character in the first character set to the corresponding character in the second character set. The function can, for example, translate ‘Ελλασ’ to ‘Ellas’. But it can’t translate ‘Ελλασ’ to ‘Greece’.

Numeric value functions Numeric value functions can take a variety of data types as input, but the output is always a numeric value. SQL has 13 types of numeric value functions: ⻬ Position expression (POSITION) ⻬ Extract expression (EXTRACT) ⻬ Length expression (CHAR_LENGTH, CHARACTER_LENGTH, OCTET_LENGTH) ⻬ Cardinality expression (CARDINALITY) ⻬ Absolute value expression (ABS) ⻬ Modulus expression (MOD) ⻬ Natural logarithm (LN) ⻬ Exponential function (EXP) ⻬ Power function (POWER) ⻬ Square root (SQRT) ⻬ Floor function (FLOOR) ⻬ Ceiling function (CEIL, CEILING) ⻬ Width bucket function (WIDTH_BUCKET)

157


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.