Missing SELECT INTO ... DEFAULT VALUES in plpgsql for composite t
am 22.11.2004 17:43:44 von Vadim.PassynkovHi all
Just self-explanatory code below
-- var1 with default value.
CREATE DOMAIN var1_type AS pg_catalog.text
DEFAULT 'udp'::pg_catalog.text
CONSTRAINT "var1_const"
CHECK ( VALUE IS NOT NULL AND ( VALUE = 'tcp'::pg_catalog.text OR VALUE =
'udp'::pg_catalog.text ) );
-- var2 without default
CREATE DOMAIN var2_type AS pg_catalog.int4
CONSTRAINT "var2_const"
CHECK ( VALUE IS NOT NULL AND VALUE > 0 );
-- Let's create composite type foo
CREATE TABLE foo (
var1 var1_type,
var2 var2_type
);
-- and let's create constructor for it
CREATE OR REPLACE FUNCTION foo ( int4 ) RETURNS foo AS '
DECLARE
this foo;
BEGIN
/*
* I dont want hard coded default
* value for this.var1 here
* but SELECT INTO this DEFAULT VALUES not possible in plpgsql
*/
-- SELECT INTO this DEFAULT VALUES;
this.var2 := $1;
RETURN this;
END;
' LANGUAGE 'plpgsql' IMMUTABLE STRICT;
SELECT * from foo ( 2 );
var1 | var2
------+------
| 2
(1 row)
but I want
var1 | var2
------+------
udp | 2
(1 row)
Is anybody know any solution for this?
--
Vadim Passynkov
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org