Re: SELECT CAST(123 AS char) -> 1

From: "Dean Gibson (DB Administrator)" <postgresql(at)ultimeth(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT CAST(123 AS char) -> 1
Date: 2008-02-13 02:53:58
Message-ID: 47B25BC6.1080702@ultimeth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2008-02-12 16:17, Ken Johanson wrote:
> Dean Gibson (DB Administrator) wrote:
> ...
>
> I'm guessing you declare an explicit length of 1 (for portability), or
> do you "CAST (x as char)"? And one might ask in what context we'd need
> CHAR(1) on a numeric type, or else if substr/ing or left() make the
> code more readable for other data types..
>

Actually, I just write "CHAR" for a length of 1.

> > What is wrong with using VARCHAR for your
> purpose????????????????????????????
>
> Simply that a commonly used database (my) does not support it.

By "my", do you mean "MySQL", or "MyDatabase"? If the latter, then
while it's your business decision (and/or that of your customers), the
availability of decent, free databases should make a compelling case for
anyone using anything else, to migrate (and never look back) to
something full-featured.

It's like requiring portable C code to use the old, pre-ANSI style of
function declarations, because some old C compilers might not support
the ANSI style. I think Richard Stallman of the FSF takes that
position, but I don't know of anyone else (although I'm sure there are
exceptions).

--
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andy Colson 2008-02-13 03:14:56 Re: Storing images as BYTEA or large objects
Previous Message Ken Johanson 2008-02-13 00:48:37 Re: SELECT CAST(123 AS char) -> 1