[SQL] exists and is not null equivalence in query

2009-05-28 Thread Raphael Bauduin
Hi, In some code I am taking over, I found this query: select count(t.trame_id) as count, v.voiture_num as voitureNum from arch_trames t left join voiture v on (v.tag_id=t.tag_id) where (t.recept_time >= 1243509320691) and exists (select v2.voiture_num from voiture v2 where v2.tag_id=v.tag_id)

Re: [SQL] inserting boolean values in dynamic queries

2008-09-18 Thread Raphael Bauduin
On Thu, Sep 18, 2008 at 2:35 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Raphael Bauduin" <[EMAIL PROTECTED]> writes: >> EXECUTE 'UPDATE tbl SET ' >> || quote_ident(colname) >> || ' = ' >> || quote_litera

[SQL] inserting boolean values in dynamic queries

2008-09-18 Thread Raphael Bauduin
Hi, I'm building a dynamic query as described at http://www.postgresql.org/docs/8.3/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN : EXECUTE 'UPDATE tbl SET ' || quote_ident(colname) || ' = ' || quote_literal(newvalue) || ' WHERE key = '

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2008-09-17 Thread Raphael Bauduin
On Wed, Sep 17, 2008 at 5:45 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > On Wed, Sep 17, 2008 at 05:08:39PM +0200, Raphael Bauduin wrote: >> Would you have a little example on how you would do it? > > show us what you have done - it will be easier to find/fix/ex

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2008-09-17 Thread Raphael Bauduin
HI, On Sat, Aug 11, 2007 at 9:07 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > On Sat, Aug 11, 2007 at 02:45:09AM -0500, Javier Fonseca V. wrote: >> I think that it's working alright except for the next line: > > doing this in plpgsql is very complicated (or even impossible assuming >

Re: [SQL] difference between EXCEPT and NOT IN?

2008-04-01 Thread Raphael Bauduin
On Tue, Apr 1, 2008 at 6:04 PM, Stephan Szabo <[EMAIL PROTECTED]> wrote: > On Tue, 1 Apr 2008, Raphael Bauduin wrote: > > > The 2 following statements don't give the same result. I expected the > > second ti give the exact same result as the first one. > >

[SQL] difference between EXCEPT and NOT IN?

2008-04-01 Thread Raphael Bauduin
Hi, The 2 following statements don't give the same result. I expected the second ti give the exact same result as the first one. What am I missing? development=> SELECT id FROM entrees except select entree_id from postes ORDER BY id desc; id -- 3651 (1 row) development=> SELECT id FROM e