December 29th, 2008

CONVERT (chg. to new chars.)

The CONVERT function changes the representation of a character string within its character set.

 

Format: CONVERT(value, USING conversion_char_name)

 

> Access supports CONVERT with a very different format.

> Oracle supports CONVERT but the format is CONVERT(value, target_char_set, source_char_set).

> PostgreSQL supports CONVERT and conversions can be defined using CREATE CONVERSION.

> SQL Server’s CONVERT is very different and is similar to the CAST function.

> DB2, and MySQL, do not support CONVERT.

December 26th, 2008

Concatenate || (attach values), Part 4 of 4

If we have a table: ACCOUNTS_PAYABLE_TBL

Return VNDR_ID, INVN_ID, AMT_DUE, and then place ‘–> ‘ ahead of the NOTES and ‘ <–’ behind the NOTES column.

          SELECT VNDR_ID,
                 INVN_ID,
                 AMT_DUE,
                 '--> ' || NOTES || ' <--'
            FROM ACCOUNTS_PAYABLE_TBL;

Result Table:

 The trailing constant ‘ <–’ “floated” to the left behind the NOTES value
because the NOTES column is defined as VARCHAR.

December 25th, 2008

Concatenate || (attach values), Part 3 of 4

If we have a table: VENDOR_TBL

If you concatenate the STATE and the COUNTRY columns, you get the following results:

          SELECT STATE || COUNTRY
            FROM VENDOR_TBL;

Normally-defined character values are padded with spaces to the
length of the column definition.
The concatenation of multiple character columns does not add or
eliminate trailing spaces.
If the column is defined as variable (VARCHAR), then the length
is determined by the inserted value which may or may not
include leading or trailing spaces.

Result Table:

                    

« Previous PageNext Page »