Using function like where clause

Started by Ranieri Maziliover 18 years ago3 messagesgeneral
Jump to latest
#1Ranieri Mazili
ranieri.oliveira@terra.com.br

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

#2Michael Glaesemann
grzm@seespotcode.net
In reply to: Ranieri Mazili (#1)
Re: [SQL] Using function like where clause

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

#3Ragnar
gnari@hive.is
In reply to: Ranieri Mazili (#1)
Re: [SQL] Using function like where clause

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