pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedinsertable views - not copy-able ?
3+ messages / 3 participants
[nested] [flat]
* insertable views - not copy-able ?
@ 1999-10-17 20:56 Daniel Péder <dpeder@infoset.cz>
1999-10-18 08:53 ` Re: [HACKERS] insertable views - not copy-able ? Jan Wieck <wieck@debis.com>
1999-10-19 13:25 ` Re: [SQL] insertable views - not copy-able ? Herouth Maoz <herouth@oumail.openu.ac.il>
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Péder @ 1999-10-17 20:56 UTC (permalink / raw)
To: 'pgsql-hackers@postgresql.org' <pgsql-hackers@postgresql.org>; pgsql-sql
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;
Enter info followed by a newline
End with a backslash and a period on a line by itself.
>> jim
>> john
>> jack
>> \.
mydb=> select MYVIEW.*;
name
----
(0 rows)
--
dan peder
dpeder@infoset.cz
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [HACKERS] insertable views - not copy-able ?
1999-10-17 20:56 insertable views - not copy-able ? Daniel Péder <dpeder@infoset.cz>
@ 1999-10-18 08:53 ` Jan Wieck <wieck@debis.com>
1 sibling, 0 replies; 3+ messages in thread
From: wieck@debis.com @ 1999-10-18 08:53 UTC (permalink / raw)
To: dpeder@infoset.cz; +Cc: pgsql-hackers@postgreSQL.org; pgsql-sql
>
> 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;
First this setup wouldn't work with INSERT too. The INSTEAD
rule for INSERT is missing. Second COPY isn't a rewritable
statement, and it will not become such since only commands
that have a rangetable and a targetlist can be handled by the
rewriter at all.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck@debis.com (Jan Wieck) #
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [SQL] insertable views - not copy-able ?
1999-10-17 20:56 insertable views - not copy-able ? Daniel Péder <dpeder@infoset.cz>
@ 1999-10-19 13:25 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1 sibling, 0 replies; 3+ messages in thread
From: Herouth Maoz @ 1999-10-19 13:25 UTC (permalink / raw)
To: Daniel Péder <dpeder@infoset.cz>; 'pgsql-hackers@postgresql.org' <pgsql-hackers@postgreSQL.org>; pgsql-sql
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1999-10-19 13:25 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-10-17 20:56 insertable views - not copy-able ? Daniel Péder <dpeder@infoset.cz>
1999-10-18 08:53 ` Jan Wieck <wieck@debis.com>
1999-10-19 13:25 ` Herouth Maoz <herouth@oumail.openu.ac.il>
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