I have a problem when I try to update many rows at the same time.
Here is the table and query I use (simplified for better reading):
table<
If you have a script generating the query you could extract and cache the data type of each column an create the type cast accordingly. E.g:
SELECT column_name,data_type,udt_name
FROM information_schema.columns
WHERE table_name = 'foo';
From this udt_name you'll get the necessary cast as you explained in the last paragraph. Additionally you could do this:
UPDATE foo
SET x = t.x
FROM (VALUES(null::int4,756),(null::int4,6300))
AS t(x,pkid)
WHERE foo.pkid = t.pkid;