dump data into table with sequence
Anton Stckl <tony@cys.de>
From: "Anton Stckl" <tony@cys.de>
To: pgsql-general@postgresql.org
Date: 1998-05-13T10:24:27Z
Lists: pgsql-general
Given this table: Table = rechnung_kunde_199805 +----------------------------------+-------------------------------------+-------+ | Field | Type | Length| +----------------------------------+-------------------------------------+-------+ | rechnungs_id | int4 default nextval ( 're_id_seq') | 4 | | kunden_nr | int4 | 4 | | stream_name | varchar() | 40 | | offset | int4 | 4 | | length | int4 | 4 | | datum | date | 4 | +----------------------------------+-------------------------------------+-------+ There is a unique index on rechnungs_id and a sequence 're_id_seq'. I want to insert loads of data into this table -> 'psql DB < data.sql' data.sql is like: 'COPY .. FROM stdin;' __data__ \. and the 'first field == rechnungs_id' in the data is empty (just a tab). This doesn't work as PG tries to insert NULL as value for rechnungs_id instead of using the sequence. Q: Is there a way to solve that problem other then defining a trigger? If not: Q: Can someone give me an example how to define the trigger (and the procedure?) here? I have read the docs (+ the contrib stuff), but still don't know exactly how to implement that. regards, Tony -- ----------C-Y-B-E-R-S-O-L-U-T-I-O-N-S---------------- Anton Stöckl mailto:tony@cys.de CyberSolutions GmbH http://www.cys.de Frankfurter Ring 193A Phone +49 89 32369223 80807 Muenchen Fax +49 89 32369220 ------W-E----M-A-K-E----I-T----P-O-S-S-I-B-L-E-------