select where true, or select where input = '$var'

Поиск
Список
Период
Сортировка
От zach cruise
Тема select where true, or select where input = '$var'
Дата
Msg-id CAL8icXzM6DPeM70szCeX56RyGJoO2emrxM9GBXWV1DJERo1bsw@mail.gmail.com
обсуждение исходный текст
Ответы Re: select where true, or select where input = '$var'  (John R Pierce <pierce@hogranch.com>)
Re: select where true, or select where input = '$var'  (Paul Jungwirth <pj@illuminatedcomputing.com>)
Re: select where true, or select where input = '$var'  (Alban Hertroys <haramrae@gmail.com>)
Re: select where true, or select where input = '$var'  (John R Pierce <pierce@hogranch.com>)
Список pgsql-general
i want to select based on input, but if input is not provided or if
input is empty, then i want to select all rows.

1 select *
2 from table
3 if input = '' then
4  where true
5 else
6  where input = '$sanitized_variable'
7 end if;
(syntax error at 3)

i also looked at 'case' but i don't think it applies here.

http://www.postgresql.org/docs/9.3/static/functions-conditional.html
http://dba.stackexchange.com/questions/41067/getting-select-to-return-a-constant-value-even-if-zero-rows-match


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

Предыдущее
От: Dmitry O Litvintsev
Дата:
Сообщение: Re: postgresql93-9.3.5: deadlock when updating parent table expected?
Следующее
От: Juan Pablo L
Дата:
Сообщение: rollback in C functions