Обсуждение: Insert Statement & Composite Type
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@none.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
Grant
"Grant Martin" <grantwgmartin@live.com> writes: > What is the correct INSERT statement syntax to insert a composite > type into a table of that type. This should work: INSERT INTO licencee VALUES(new_licencee.*); regards, tom lane