Insert Statement & Composite Type

From: "Grant Martin" <grantwgmartin(at)live(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Insert Statement & Composite Type
Date: 2012-09-08 08:33:24
Message-ID: BLU161-ds151017CE496288D687A97D0AE0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,
What is the correct INSERT statement syntax to insert a composite type into a table of that type. For example given the following table:

CREATE TABLE licencee
(
id integer NOT NULL DEFAULT nextval('licencee_id_seq'::regclass),
email character varying(254),
salutation character varying(20),
first_name character varying(256),
middle_name character varying(256),
last_name character varying(256),
suffix character varying(20),
locale character varying(20),
business_name character varying(256),
CONSTRAINT licencee_pkey PRIMARY KEY (id )
)
WITH (
OIDS=FALSE
)

How can I write an INSERT procedure like:

CREATE FUNCTION create_licencee(new_licencee licencee) RETURNS boolean AS $$
BEGIN
INSERT INTO licencee new_licencee;
RETURN true;
END;
$$ LANGUAGE plpgsql;

create_licencee((2, mailto:'email(at)none(dot)com', Mr,Fred, , Flintstone, , locale,, male)::licencee);

Do I have to fully qualify each column name? It would seem redundant in this case.

Thanks,
Grant

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2012-09-08 15:12:33 Re: Insert Statement & Composite Type
Previous Message Tom Lane 2012-09-06 20:19:42 Re: On naming of executables