From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Daniel Péder <dpeder@infoset.cz>
To: 'pgsql-hackers@postgresql.org' <pgsql-hackers@postgreSQL.org>
To: 'pgsql-sql@postgresql.org' <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] insertable views - not copy-able ?
Date: Tue, 19 Oct 1999 15:25:19 +0200
Message-ID: <l03130302b43220c310b0@[147.233.159.109]> (raw)
In-Reply-To: <01BF18EA.81DB25A0@Dan>
At 22:56 +0200 on 17/10/1999, =?iso-8859-2?Q?Daniel_P=E9der?= wrote:
> what about this:
> ( it would be nice to have it working, specially for copying values from
>files into table with default fields, having the default fields doing
>their job or initialising tables using reduced set of columns )
>
> mydb=> create sequence MYSEQ;
> CREATE
> mydb=> create table MYTAB ( ID int4 default nextval('MYSEQ'), NAME text );
> CREATE
> mydb=> create view MYVIEW as select name from MYTAB;
> CREATE
> mydb=> copy MYVIEW from stdin;
Seems this view is neither insertable nor copyable. To make it insertable,
you have to define a rule, you know.
In any case, I don't think it would work for copy - the rule I mean.
IMO, if you want to copy data and have defaults work, you copy the data
into a temporary table with only the necessary fields, and then issue an
insert:
CREATE TEMP TABLE tmp_tab ( name text );
COPY tmp_tab FROM stdin;
jim
john
jack
\.
INSERT INTO mytab (name) SELECT name FROM tmp_tab;
DROP TABLE tmp_tab;
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: herouth@oumail.openu.ac.il, dpeder@infoset.cz, pgsql-hackers@postgreSQL.org
Subject: Re: [SQL] insertable views - not copy-able ?
In-Reply-To: <l03130302b43220c310b0@[147.233.159.109]>
References: <01BF18EA.81DB25A0@Dan> <l03130302b43220c310b0@[147.233.159.109]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox