| От | David W Noon |
|---|---|
| Тема | Re: Let-bindings in SQL statements |
| Дата | |
| Msg-id | 20120126162917.798487f4@karnak.local обсуждение исходный текст |
| Ответ на | Let-bindings in SQL statements (Jon Smark <jon.smark@yahoo.com>) |
| Список | pgsql-general |
On Thu, 26 Jan 2012 06:37:49 -0800 (PST), Jon Smark wrote about [GENERAL] Let-bindings in SQL statements: >Is it possible to do the equivalent of let-bindings in a pure SQL >function? I have a SELECT that invokes "now" multiple times. It would >be nicer to do it only once and reuse the value. Something like this: > >LET right_now = SELECT now () IN >SELECT * FROM my_table WHERE right_now >= start AND ... > >In PL/pgSQL this is easy, but I wonder about SQL... Try using CURRENT_TIMESTAMP instead. In fact, CURRENT_TIMESTAMP is more traditional SQL than now(). I don't have an ANSI standard handy, so I cannot be certain when now() was added, if ever; but I have been using CURRENT TIMESTAMP (space instead of vinculum) under DB2 for 20 years or more. -- Regards, Dave [RLU #314465] *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* dwnoon@ntlworld.com (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера