[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] PostgreSQL - slette og oprette tabel



Peter Rude wrote:

> Hej!
> 
> Jeg har slettet en tabel "ordrelinjer"
>  >> pg_query("DROP TABLE ordrelinjer");  <<
> 
>   i en postgresdatabase og oprettet en ny af samme navn.
> 
>      pg_query("CREATE TABLE ordrelinjer (id serial NOT NULL, varenr
> character(25), text character(60), posnr smallint, pris numeric, rabat
> numeric, PRIMARY KEY (id))");
> 
> 
> Når jeg nu forsøger indsætte data i tabellen får jeg følgende fejl:
> 
> Warning: pg_query(): Query failed: ERROR: Cannot insert a duplicate key
> into unique index ordrelinjer_pkey
> 
> Nogen tips?
> 
> Mvh Peter

Hur har du det med transaktioner?

begin
  drop table
  create table
  insert into table
commit

borde misslyckas eftersom postgres inkluderar ddl statements i
transaktionerna, inte bara dml statements..



begin
  drop table
commit
begin
  create table
  insert into table
commit


borde lyckas

-- 
/Björn
-------------------------------------------------------------------
http://lundin.homelinux.net
Registered Linux User No. 267342 <http://counter.li.org>


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *