Re: [GENERAL] Let-bindings in SQL statements

2012-02-14 Thread Marti Raudsepp
On Sat, Feb 11, 2012 at 12:42, Jasen Betts wrote: > There is no need. now() is tagged as stable. it will only be executed once. > the planner will figure this out for you. Actually that's not always true. In index condition arguments, the expression would indeed be executed just once. But in filt

Re: [GENERAL] Let-bindings in SQL statements

2012-02-13 Thread Jasen Betts
On 2012-01-26, David W Noon wrote: > > 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 vi

Re: [GENERAL] Let-bindings in SQL statements

2012-02-13 Thread Jasen Betts
On 2012-01-26, David Johnston wrote: > 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: There is no need. now() is tagged as stable.

Re: [GENERAL] Let-bindings in SQL statements

2012-01-26 Thread Filip Rembiałkowski
On Thu, Jan 26, 2012 at 3:37 PM, Jon Smark wrote: > Hi, > > 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 = SELEC

Re: [GENERAL] Let-bindings in SQL statements

2012-01-26 Thread David W Noon
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

Re: [GENERAL] Let-bindings in SQL statements

2012-01-26 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Jon Smark Sent: Thursday, January 26, 2012 9:38 AM To: pgsql-general@postgresql.org Subject: [GENERAL] Let-bindings in SQL statements Hi, Is it possible to do the

Re: [GENERAL] Let-bindings in SQL statements

2012-01-26 Thread Szymon Guz
On 26 January 2012 15:37, Jon Smark wrote: > Hi, > > 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 (

[GENERAL] Let-bindings in SQL statements

2012-01-26 Thread Jon Smark
Hi, 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