在Linux上发布Postgres 8.1。
当我尝试:
insert into card(
routine_id, page, row, col, show_card, flip_card
)
select (
999, 0, 0, 0, show_card, flip_card
) from card WHERE
routine_id = 89 AND page = 0 AND row = 0 AND col = 0
;
我明白了:
ERROR: column "routine_id" is of type integer but expression is of type record
HINT: You will need to rewrite or cast the expression.
select返回一个名为“row record”的列,如下所示:(999,0,0,0,1,0)
谷歌搜索表明我的语法是SQL正确的,也许这是一个Postgres偏差??
答案 0 :(得分:1)
在SELECT之后删除括号。
INSERT INTO card
(routine_id, page, row, col, show_card, flip_card)
SELECT 999, 0, 0, 0, show_card, flip_card
FROM card
WHERE routine_id = 89 AND page = 0 AND row = 0 AND col = 0;
答案 1 :(得分:0)
消除选择部分周围的括号:
insert into card (routine_id, page, row, col, show_card, flip_card)
select 999, 0, 0, 0, show_card, flip_card
from card
WHERE routine_id = 89 AND page = 0 AND row = 0 AND col = 0;
答案 2 :(得分:0)
似乎将括号括起来使Postgres将其视为“行记录”。我想,删除括号会使它工作,因为结果集只是一个带有值的单独列的列表