From: | Dmitriy Igrishin <dmitigr(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>, Viktor Bojović <viktor(dot)bojovic(at)gmail(dot)com>, "PostgreSQL (SQL)" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Finding Max Value in a Row |
Date: | 2012-05-15 11:00:28 |
Message-ID: | CAAfz9KMQ_tnnQE=14XfM0cMyToT=Q44EWDDeuJrmjsdZv6_Z1w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
2012/5/14 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com> writes:
> > I'm not understanding why I'm not able to change this column type from
> > char to integer?
>
> > forza=# ALTER TABLE customers
> > ALTER COLUMN cust_id TYPE integer;
> > ERROR: column "cust_id" cannot be cast to type integer
>
> Try "ALTER ... cust_id TYPE integer USING cust_id::integer".
>
> If you don't specify a USING expression, the command requires an
> implicit coercion from one type to the other, and there is none from
> char(n) to int. You can force it with an explicit coercion, though.
>
> It strikes me that "cannot be cast" is a poor choice of words here,
> since the types *can* be cast if you try. Would it be better if the
> message said "cannot be cast implicitly to type foo"? We could also
> consider a HINT mentioning use of USING.
>
Tom, as usual you are right. I find it reasonable to improve the
message and to add the hint into an error report in this case.
--
// Dmitriy.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2012-05-15 11:01:04 | Re: SELECT 1st field |
Previous Message | Misa Simic | 2012-05-15 08:06:14 | Re: SELECT 1st field |