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

From Clark Evans
Subject Re: [GENERAL] 88, CREATE FUNCTION ON TABLE
Date
Msg-id 369161B4.3FE8DB5A@manhattanproject.com
Whole thread Raw
In response to 88, CREATE FUNCTION ON TABLE  (Clark Evans <clark.evans@manhattanproject.com>)
List 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

pgsql-general by date:

Previous
From: "Jackson, DeJuan"
Date:
Subject: RE: [GENERAL] Subselect question
Next
From: Anand Surelia
Date:
Subject: Regression test failing on Sparc Solaris 2.5.1