Thread: Using function like where clause

Using function like where clause

From
Ranieri Mazili
Date:
Hello,

I have 2 questions.
1) Can I use a function that will return a string in a where clause like
bellow?

select *
from table
where my_function_making_where()
          and another_field = 'another_think'

2) Can I use a function that will return a string to return the list of
columns that I want to show like below?

select my_function_making_list_of_columns()
from table
where field_test = 'mydatum'

Thanks

Re: Using function like where clause

From
Michael Glaesemann
Date:
On Aug 6, 2007, at 14:44 , Ranieri Mazili wrote:

> 1) Can I use a function that will return a string in a where clause
> like bellow?
>
> select *
> from table
> where my_function_making_where()
>          and another_field = 'another_think'

Probably. What have you tried? What does the documentation say? If
you're having trouble with a specific function, please provide the
code and hopefully we can work it out.

> 2) Can I use a function that will return a string to return the
> list of columns that I want to show like below?
>
> select my_function_making_list_of_columns()
> from table
> where field_test = 'mydatum'

Probably not. What have you tried? What does the documentation say?

A couple of minutes in psql would probably be faster than sending an
email to the list.

Michael Glaesemann
grzm seespotcode net



Re: Using function like where clause

From
Ragnar
Date:
On mán, 2007-08-06 at 16:44 -0300, Ranieri Mazili wrote:
> 1) Can I use a function that will return a string in a where clause like
> bellow?
>
> select *
> from table
> where my_function_making_where()
>           and another_field = 'another_think'

you could have your function return a boolean instead of a string


> 2) Can I use a function that will return a string to return the list of
> columns that I want to show like below?
>
> select my_function_making_list_of_columns()
> from table
> where field_test = 'mydatum'

no

gnari