select only default

From: Nabil Sayegh <postgresql(at)e-trolley(dot)de>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: select only default
Date: 2003-05-15 23:32:03
Message-ID: 1053041523.979.16.camel@billy
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all,

just for curiosity:

Is it possible to SELECT a row that consists only of default values of a
table ?

Let's suppose I have a Table:

CREATE TEMP TABLE tempo
(
a int DEFAULT 5,
b text DEFAULT 'five'
);

I want as a result:

(5, 'five')

But without inserting a row.

Is this possible with 1 query ?

I thought of something like OUTER JOINS where you get defaults for
non-existing rows, too.

What I need this for ?
I want to present users a form for inserting new rows. The form should
be loaded with default values.

Of course I can do it without SQL, but I thought, hey, that'd be cool in
plain SQL.

BTW: The DEFAULT values are all 'simple' types, no serials etc. included

TIA
--
e-Trolley Sayegh & John, Nabil Sayegh
Tel.: 0700 etrolley /// 0700 38765539
Fax.: +49 69 8299381-8
PGP : www.e-trolley.de

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2003-05-16 02:30:59 Re: select only default
Previous Message Fontenot, Paul 2003-05-15 19:53:57