Re[2]: [GENERAL] 88, CREATE FUNCTION ON TABLE

From: Sferacarta Software <sferac(at)bo(dot)nettuno(dot)it>
To: Clark Evans <clark(dot)evans(at)manhattanproject(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re[2]: [GENERAL] 88, CREATE FUNCTION ON TABLE
Date: 1999-01-07 13:35:54
Message-ID: 17608.990107@bo.nettuno.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello Clark,

martedì, 5 gennaio 99, you wrote:

CE> Jose',

CE> Thank you for your response.

>> --COBOL level 88 using functions-----------------------------------------------
>>
>> drop function current_client(text);
>> create function current_client(text) returns bool as '
>> DECLARE
>> status ALIAS for $1;
>> BEGIN
>> RETURN status IN (''A'',''a'',''P'',''p'');
>> END;
>> ' language 'plpgsql';
>>
>> drop function active_client(text);
>> create function active_client(text) returns bool as '
>> DECLARE
>> status ALIAS for $1;
>> BEGIN
>> RETURN status IN (''A'',''a'');
>> END;
>> ' language 'plpgsql';
>>
>> select * from customer
>> where active_client(customer_status);
>>
>> select * from customer
>> where not active_client(customer_status);

CE> I guess what I was wondering... perhaps plpgsql
CE> could have an "automatic" local variable, say
CE> "current_row" so that the "text" would not have
CE> to be passed in... Thus

CE> create function current_client returns bool as '
CE> BEGIN
CE> RETURN current_row.status IN (''A'',''a'',''P'',''p'');
CE> END;
CE> ' language 'plpgsql';

CE> Then the select could look like this:

CE> select * from customer where active_client;

CE> Thoughts?

AFAIK you can't call a function without specify parens.
Over more, if you specify a function without parameters or with
constants as parameters, the function will be called once on first
tuple.
A WHERE condition function is called for every tuple only if it has
variable parameters (column name, expression, etc).

-Jose'-

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Evan Howarth 1999-01-07 14:14:27 RE: [GENERAL] We are doing great things with PostgreSQL
Previous Message Holger Klawitter 1999-01-07 09:24:56 [GENERAL] Subject: String Concatenation DOES work.