Postgres syntax error with INSERT in TableFoo SELECT from TableFoo.

advertisements

Postgres 8.1 on linux.

When I try:

   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
                ;

I get:

ERROR:  column "routine_id" is of type integer but expression is of type record
HINT:  You will need to rewrite or cast the expression.

The select gives back a single column called "row record" that looks like this: (999,0,0,0,1,0)

Googling suggests that my syntax is SQL correct, perhaps this is a Postgres deviation??


Drop the parentheses after the 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;