pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCreate an empty record
3+ messages / 2 participants
[nested] [flat]
* Create an empty record
@ 2001-05-19 19:24 Per-Olof Pettersson <pgsql@peope.net>
0 siblings, 2 replies; 3+ messages in thread
From: Per-Olof Pettersson @ 2001-05-19 19:24 UTC (permalink / raw)
To: pgsql-general@postgresql.org.pgsql-sql
Hi
How would one goabout creating an empty record (for use in relations).
Eg
create table product(
productid SERIAL NOT NULL,
product TEXT,
PRIMARY KEY(productid)
);
create table product_billable(
productid INT4 NOT NULL,
billaddress TEXT,
PRIMARY KEY (productid),
FOREIGN KEY (productid) REFERENES product(productid) ON DELETE CASCADE
);
All fields except for the primary key can be NULL.
What if I wanted to add a new billable product but I have not got a name
for it yet?
So how could I insert a new record in product that can be used in
product_billable?
I have tried INSERT INTO product() VALUES(); but as expected it did not
work.
All help appreciated
Best regards
Per-Olof Pettersson
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Create an empty record
@ 2001-05-19 19:32 Per-Olof Pettersson <pgsql@peope.net>
parent: Per-Olof Pettersson <pgsql@peope.net>
1 sibling, 0 replies; 3+ messages in thread
From: Per-Olof Pettersson @ 2001-05-19 19:32 UTC (permalink / raw)
To: pgsql-general@postgresql.org.pgsql-sql
Oh I forgot
Naturally it works with setting eg procuct in this case to null but it
does not seem very clean.
INSERT INTO product(product) VALUES(null);
Does anybody have a clean way to do this?
Best regards
Per-Olof Pettersson
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
On 2001-05-19, 21:24:54, Per-Olof Pettersson <pgsql@peope.net> wrote
regarding Create an empty record:
> Hi
> How would one goabout creating an empty record (for use in relations).
> Eg
> create table product(
> productid SERIAL NOT NULL,
> product TEXT,
> PRIMARY KEY(productid)
> );
> create table product_billable(
> productid INT4 NOT NULL,
> billaddress TEXT,
> PRIMARY KEY (productid),
> FOREIGN KEY (productid) REFERENES product(productid) ON DELETE
CASCADE
> );
> All fields except for the primary key can be NULL.
> What if I wanted to add a new billable product but I have not got a name
> for it yet?
> So how could I insert a new record in product that can be used in
> product_billable?
> I have tried INSERT INTO product() VALUES(); but as expected it did not
> work.
> All help appreciated
> Best regards
> Per-Olof Pettersson
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Create an empty record
@ 2001-05-19 20:45 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Per-Olof Pettersson <pgsql@peope.net>
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2001-05-19 20:45 UTC (permalink / raw)
To: Per-Olof Pettersson <pgsql@peope.net>; +Cc: pgsql-general@postgresql.org; pgsql-sql
I believe it's:
insert into product default values;
(Don't blame us, blame the standard... :) )
On Sat, 19 May 2001, Per-Olof Pettersson wrote:
> Hi
>
> How would one goabout creating an empty record (for use in relations).
>
> I have tried INSERT INTO product() VALUES(); but as expected it did not
> work.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-05-19 20:45 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-19 19:24 Create an empty record Per-Olof Pettersson <pgsql@peope.net>
2001-05-19 19:32 ` Per-Olof Pettersson <pgsql@peope.net>
2001-05-19 20:45 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
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