I try to select values from one xml field and insert selected values to another table field with integer type.
QUERY:
INSERT INTO "Match"
select
unnest(xpath('./game/id/text()', "File"))
FROM "Files"
Select works fine, but when I try to insert, then error occurs:
SQL error:
ERROR: column "id" is of type integer but expression is of type xml
LINE 3: unnest(xpath('./game/id/text()', "File")),
HINT: You will need to rewrite or cast the expression.
When I try to change xml type with cast, then I get another error:
SQL error:
ERROR: cannot cast type xml to integer
LINE 3: cast(unnest(xpath('./game/id/text()', "File"))as integer)
And when I try to change type with XMLSERIALIZE, then another error occurs:
SQL error:
ERROR: argument of XMLSERIALIZE must not return a set
LINE 3: XMLSERIALIZE(CONTENT unnest(xpath('./game/id/text()', "File"...
How can I insert selected values to another table?