Re: Blank SQL insert statements - Mailing list pgsql-general

From Allan Engelhardt
Subject Re: Blank SQL insert statements
Date
Msg-id 3BCD53AB.9030404@cybaea.com
Whole thread Raw
In response to Blank SQL insert statements  ("Ashley @ Turton" <ashley@turton.com>)
List pgsql-general
I'm not really recommending what you are trying to do [I prefer an INSERT with
all the values instead of UPDATE-ing the table multiple times...], but

  INSERT INTO x DEFAULT VALUES;

should more or less do what you want.  Of course the table must have default
values defined to satisfy any constraints or you can't sensibly insert an
'empty' column.

Allan.

Ashley @ Turton wrote:

> I am developing a system to take a generic data structure and store it in a
> PostgreSQL database.  The data structure contains several entries of the
> following:
>
> insert a record into table1
> field1  value1
> field2  value2
>
> insert a record into table2
> field1  value1
> field2  value2
>
> Data for different tables is stored in each 'data set'.  When I get this to
> the database I want to:
>
> insert a blank record into tablex
> populate fieldx of new record with valuex
>
> I could implement this with some if statements based on the table name, then
> INSERT INTO x (...) VALUES (...), but I would prefer to kept the structure
> as generic as possible.  Is it possible in PostgreSQL to construct a blank
> record without specifying a list of fields and values in an INSERT statement
> (so I can perform a collection for UPDATEs to populate the blank record)?
>
>
> Ashley
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


pgsql-general by date:

Previous
From: Allan Engelhardt
Date:
Subject: Re: postgresql 7.1.3
Next
From: Allan Engelhardt
Date:
Subject: What is the syntax for unicode characters?