Re: Passing a WHERE clause by trigger to a function

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: Passing a WHERE clause by trigger to a function
Дата
Msg-id 1370350032292-5757877.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Passing a WHERE clause by trigger to a function  (Melvin Call <melvincall979@gmail.com>)
Ответы Re: Passing a WHERE clause by trigger to a function  (Melvin Call <melvincall979@gmail.com>)
Список pgsql-general
Melvin Call wrote
> But I still have a question in that I'd like to know if I can pass the
> WHERE clause to the function so it can examine the query? Or will I have
> to
> test for the potential of acting on more than one row?

You can write a function that takes a text/varchar and builds a dynamic SQL
query that then is executed...but I highly advise against it. Basically you
open yourself to SQL injection attack vectors and passing in a where clause
to a function is a very non-intuitive and cumbersome API.

What you likely want are functions that do what you want and take a person
id as an input.  Let the user decide the best way to obtain that person id.

David J.






--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Passing-a-WHERE-clause-by-trigger-to-a-function-tp5757825p5757877.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: Melvin Call
Дата:
Сообщение: Re: Passing a WHERE clause by trigger to a function
Следующее
От: Andres Freund
Дата:
Сообщение: Re: More buffers used than a relation's relpages