[pgsql-jp: 32496] Re: union を使ったselect結果のinsertができない 7.4.1,2
WADA Hiroyuki
wada @ komine-ag.co.jp
2004年 3月 19日 (金) 13:41:21 JST
和田です。
Mashiki wrote:
> ERROR: column "cb" is of type integer but expression is of type text
> HINT: You will need to rewrite or cast the expression.
>
> というエラーが出ます。なにが悪いのでしょうか?
NULL同士のunionだとtext型になるようですね。
解決方法はHINTに書いてあるとおりで。
wada=# create table uniontest (i int);
CREATE TABLE
wada=# insert into uniontest select null union select null;
ERROR: column "i" is of type integer but expression is of type text
HINT: You will need to rewrite or cast the expression.
wada=# insert into uniontest select null::int union select null;
INSERT 25344 1
wada=#
pgsql-jp メーリングリストの案内