[EMAIL PROTECTED] (David Fetter) wrote: > I'm looking to the SQL WITH clause as a way to get better regex > support in PostgreSQL. I've been chatting a little bit about this, > and here's an idea for a behavior. Implementation details TBD. > > WITH res = match (x.foo, '([0-9]+)x([0-9]+)') > SELECT * > FROM x > WHERE y = res[2] > OR y = res[3];
So you're proposing what amounts to the LET function in Lisp: (let* ((homepath (user-homedir-pathname)) (maildir (make-pathname :directory (append (pathname-directory homepath) '("Mail")))) (mailhome (merge-pathnames maildir homepath))) (do-something-with-mail mailhome) (do-something-with-home homepath)) Or the ML let structure... let a = 1 and b = 2 in a + b;; - : int = 3 I think this could be a "simply smashing" idea, allowing values to get declared once, up front, offering the further potential for them to be reused. Unfortunately, this doesn't seem to fit with the way WITH is defined in SQL. And while the LISP presentation may have "way too many parentheses," the ML syntax, being pretty much orthogonal to what SQL currently offers, strikes me as being preferable. -- select 'cbbrowne' || '@' || 'ntlug.org'; http://www.ntlug.org/~cbbrowne/unix.html :FATAL ERROR -- ILLEGAL ERROR ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match