SELECT'ing a function call

From: "Jared H(dot) Hudson" <jhudson(at)forefronthosting(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: SELECT'ing a function call
Date: 2001-07-06 17:25:21
Message-ID: CMEJIOHLODDLKKFPCBNDGEAOCAAA.jhudson@forefronthosting.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I would like to be able to define a table with 1 column containing user
names,
and the next column being a dynamically generating function that returns a
user's quota.

I think I see how to create the shared object, and the SQL function. But,
how
do I create a table that uses a function for a column based on the value of
another
column.

For example, I tried:

CREATE TABLE test (
num1 INTEGER,
num2 INTEGER DEFAULT add_one('num1')
);

But that said that pg_atoi doesn't understand num1 -- so apprenting atoi is
interpreting
num1 as a string, so I tried ...DEFAULT add_one(num1) which gave a different
error.

Is this even possible? To have a "trigger" based on a select statement. I
looked at the SQL
TRIGGER command and it seems to only work for INSERT, UPDATE and DELETE. I
need a "trigger"
for SELECT's.

Thanks,
Jared H.

Browse pgsql-general by date

  From Date Subject
Next Message Joshua Jore 2001-07-06 17:32:06 Re: Newbie DBD::Pg question
Previous Message Ed Loehr 2001-07-06 16:59:22 query syntax change?