,ch04.13730 Page 172 Wednesday, November 29, 2000 4:43
,ch04.13730 Page 172 Wednesday, November 29, 2000 4:43 PM format of a date conversion. Refer to the vendor documentation for more information. Following is an example: SELECT title, CONVERT(char(7), ytd_sales) FROM titles ORDER BY title GO Oracle Syntax and Variations CONVERT(’char_value’, target_char_set, source_char_set) TRANSLATE(’char_value’, ‘from_text’, ‘to_text’) Under Oracle s implementation, the CONVERT function returns the char_value in the target character set. The char_value is the string being converted, while the target_char_set is the name of the character set where the char_value is converted. Source_char_set is the name of the character set where the char_value was originally stored. Both the target and source character set can be either literals strings, variables, or columns containing the name of the character set. Note that inadequate replacement characters might be substituted when converting from or to a character set that does not support a representation of all the characters used in the conversion. Oracle supports several common character sets including US7ASCII, WE8DECDEC, WE8HP, F7DEC, WE8EBCDIC500, WE8PC850, and WE8ISO8859P1. For example: SELECT CONVERT(’Gro ‘, ‘US7ASCII’, ‘WE8HP’) FROM DUAL; ->Gross PostgreSQL Syntax and Variations TRANSLATE (character_string, from_text, to_text) PostgreSQL does not support CONVERT. PostgreSQL s implementation of the TRANSLATE function offers a large superset of functions compared to that found in the SQL99 specification. Instead, it converts any occurrence of one text string to another within another specified string. Here is an example: SELECT TRANSLATE(’12345abcde’, ‘5a’, ‘XX’); -> 1234XXbcde SELECT TRANSLATE(title, ‘Computer’, ‘PC’) FROM titles WHERE type = ‘Personal_computer’ LOWER and UPPER The functions LOWER and UPPER allow the case of a string to be altered quickly and easily, so that all the characters are lower-or uppercase, respectively. These functions are supported in all the database implementations covered in this book. 172 Chapter 4 SQL Functions
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services