Re: [GENERAL] 88, CREATE FUNCTION ON TABLE

From: Clark Evans <clark(dot)evans(at)manhattanproject(dot)com>
To: sferac(at)bo(dot)nettuno(dot)it
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] 88, CREATE FUNCTION ON TABLE
Date: 1999-01-05 00:49:56
Message-ID: 369161B4.3FE8DB5A@manhattanproject.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jose',

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);

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

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

Then the select could look like this:

select * from customer where active_client;

Thoughts?

:) Clark

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anand Surelia 1999-01-05 02:48:31 Regression test failing on Sparc Solaris 2.5.1
Previous Message Jackson, DeJuan 1999-01-04 23:23:05 RE: [GENERAL] Subselect question