Re: using queries as default value?

From: Don Patou <pknoob(at)noos(dot)fr>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: using queries as default value?
Date: 2003-05-31 02:49:18
Message-ID: 200305310449.18056.pknoob@noos.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


> Not directly, but you can fake it by hiding the query in an SQL or PL
> function that you call in the DEFAULT expression.

I tried this:

CREATE FUNCTION somefunc() RETURNS integer AS '
BEGIN
select count(colx) from anothertable;
END;
is it the right syntax?
also, how do I call my function as a default value, do I just need to "default
somefunc()" at the end of the column?

one more question, I couldn't find in the documentation how to dump databases
in a text file. could u give me the syntax?

thanx in advance

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Peter Bierman 2003-05-31 03:05:23 Re: why doesn't an index help my simple query?
Previous Message Tom Lane 2003-05-31 02:29:13 Re: why doesn't an index help my simple query?