Declare row type variable in PL/pgSQL
问题 As I found SELECT * FROM t INTO my_data; works only if: DO $$ DECLARE my_data t%ROWTYPE; BEGIN SELECT * FROM t INTO my_data WHERE id = ?; END $$; Am I right? If I want to get only 2-3 columns instead of all columns. How can I define my_data ? That is, DO $$ DECLARE my_data <WHAT HERE??>; BEGIN SELECT id,name,surname FROM t INTO my_data WHERE id = ?; END $$; 回答1: get only 2-3 columns instead of all columns One way: use a record variable: DO $$ DECLARE _rec record; BEGIN SELECT INTO _rec id,