pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Using function like where clause
6+ messages / 6 participants
[nested] [flat]

* Using function like where clause
@ 2007-08-06 19:44  Ranieri Mazili <rmazili@wgsystems.com.br>
  0 siblings, 2 replies; 6+ messages in thread

From: Ranieri Mazili @ 2007-08-06 19:44 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Using function like where clause
@ 2007-08-06 19:44  Ranieri Mazili <ranieri.oliveira@terra.com.br>
  0 siblings, 2 replies; 6+ messages in thread

From: Ranieri Mazili @ 2007-08-06 19:44 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] Using function like where clause
@ 2007-08-06 19:57  Michael Glaesemann <grzm@seespotcode.net>
  parent: Ranieri Mazili <ranieri.oliveira@terra.com.br>
  1 sibling, 0 replies; 6+ messages in thread

From: Michael Glaesemann @ 2007-08-06 19:57 UTC (permalink / raw)
  To: Ranieri Mazili <ranieri.oliveira@terra.com.br>; +Cc: pgsql-general@postgresql.org; pgsql-sql


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





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] Using function like where clause
@ 2007-08-07 18:20  Ragnar <gnari@hive.is>
  parent: Ranieri Mazili <ranieri.oliveira@terra.com.br>
  1 sibling, 0 replies; 6+ messages in thread

From: Ragnar @ 2007-08-07 18:20 UTC (permalink / raw)
  To: Ranieri Mazili <ranieri.oliveira@terra.com.br>; +Cc: pgsql-general@postgresql.org; pgsql-sql

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





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Using function like where clause
@ 2007-08-07 19:18  Kev <kevinjamesfield@gmail.com>
  parent: Ranieri Mazili <rmazili@wgsystems.com.br>
  1 sibling, 0 replies; 6+ messages in thread

From: Kev @ 2007-08-07 19:18 UTC (permalink / raw)
  To: pgsql-general@postgresql.org

On Aug 6, 3:44 pm, rmaz...@wgsystems.com.br (Ranieri Mazili) wrote:
> 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

Look up the quote_ident() function in the docs, you'll likely need
that for both cases.

Kev




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [SQL] Using function like where clause
@ 2007-08-10 08:00  hubert depesz lubaczewski <depesz@depesz.com>
  parent: Ranieri Mazili <rmazili@wgsystems.com.br>
  1 sibling, 0 replies; 6+ messages in thread

From: hubert depesz lubaczewski @ 2007-08-10 08:00 UTC (permalink / raw)
  To: Ranieri Mazili <rmazili@wgsystems.com.br>; +Cc: pgsql-general@postgresql.org; pgsql-sql

On Mon, Aug 06, 2007 at 04:44:29PM -0300, Ranieri Mazili wrote:
> 1) Can I use a function that will return a string in a where clause like 
> bellow?
> 2) Can I use a function that will return a string to return the list of 
> columns that I want to show like below?

not in sql. you can in pl/pgsql.

depesz

-- 
quicksil1er: "postgres is excellent, but like any DB it requires a
highly paid DBA.  here's my CV!" :)
http://www.depesz.com/ - blog dla ciebie (i moje CV)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2007-08-10 08:00 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-08-06 19:44 Using function like where clause Ranieri Mazili <rmazili@wgsystems.com.br>
2007-08-07 19:18 ` Kev <kevinjamesfield@gmail.com>
2007-08-10 08:00 ` hubert depesz lubaczewski <depesz@depesz.com>
2007-08-06 19:44 Using function like where clause Ranieri Mazili <ranieri.oliveira@terra.com.br>
2007-08-06 19:57 ` Michael Glaesemann <grzm@seespotcode.net>
2007-08-07 18:20 ` Ragnar <gnari@hive.is>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox