There is a composite type:

CREATE TYPE t_well AS ( id INTEGER, name VARCHAR(10), altitude NUMERIC(10,3), x NUMERIC(10,6), y NUMERIC(10,6) ); 

When using this type in queries, you must strictly follow the order of the columns in the definition. If I try to pass a variable of this type to a function:

 SELECT * FROM p_well_operations_new(1, ROW(1, 'bla', 42, 1.99, 3.45)); 

then you cannot change the order of the columns, otherwise the values ​​will be written incorrectly.

How to explicitly specify columns in a composite type? Is it even possible?

Something like this for example:

 SELECT * FROM p_well_operations_new(1, ROW(id=1, name='bla',...)); 

    1 answer 1

    There is no syntactic such construction. But you can make your own constructor function, but the function parameters can already be specified by name in any order:

     CREATE TYPE t_well AS ( id INTEGER, name VARCHAR(10), altitude NUMERIC(10,3), x NUMERIC(10,6), y NUMERIC(10,6) ); create function t_well( id INTEGER default null, name VARCHAR(10) default null, altitude NUMERIC(10,3) default null, x NUMERIC(10,6) default null, y NUMERIC(10,6) default null ) returns t_well as $function$ select row(id, name, altitude, x, y)::t_well $function$ language sql; select t_well(x => 20, y => 4.54, id => 7); t_well -------------------------- (7,,,20.000000,4.540000)