Re[2]: [GENERAL] 88, CREATE FUNCTION ON TABLE - Mailing list pgsql-general

From Sferacarta Software
Subject Re[2]: [GENERAL] 88, CREATE FUNCTION ON TABLE
Date
Msg-id 17608.990107@bo.nettuno.it
Whole thread Raw
In response to Re: [GENERAL] 88, CREATE FUNCTION ON TABLE  (Clark Evans <clark.evans@manhattanproject.com>)
List 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'-



pgsql-general by date:

Previous
From: Holger Klawitter
Date:
Subject: [GENERAL] Subject: String Concatenation DOES work.
Next
From: Evan Howarth
Date:
Subject: RE: [GENERAL] We are doing great things with PostgreSQL