Re: [SQL] UPDATE query with variable number of OR conditions in WHERE

2013-03-14 Thread Tom Lane
Ben Morrow writes: > Quoth jorgemal1...@gmail.com (JORGE MALDONADO): >> I am building an UPDATE query at run-time and one of the fields I want to >> include in the WHERE condition may repeat several times, I do not know how >> many. >> >> UPDATE table1 >> SET field1 = "some value" >> WHERE (field

Re: [SQL] UPDATE query with variable number of OR conditions in WHERE

2013-03-14 Thread Ben Morrow
Quoth jorgemal1...@gmail.com (JORGE MALDONADO): > > I am building an UPDATE query at run-time and one of the fields I want to > include in the WHERE condition may repeat several times, I do not know how > many. > > UPDATE table1 > SET field1 = "some value" > WHERE (field2 = value_1 OR field2 = va

[SQL] UPDATE query with variable number of OR conditions in WHERE

2013-03-14 Thread JORGE MALDONADO
I am building an UPDATE query at run-time and one of the fields I want to include in the WHERE condition may repeat several times, I do not know how many. UPDATE table1 SET field1 = "some value" WHERE (field2 = value_1 OR field2 = value_2 OR .OR field2 = value_n) I build such a query using a

Re: [SQL] bug in 9.2.2 ? subquery accepts wrong column name : upd

2013-03-14 Thread Tom Lane
Achilleas Mantzios writes: > dynacom=# SELECT DISTINCT ON (qry.setid) qry.setid, qry.arragg[1:2] FROM > (select distinct sst.setid,(array_agg(vsl.name) OVER (PARTITION BY > sst.setid ORDER BY character_length(vsl.name))) as arragg > FROM sissets sst, vessels vsl WHERE vsl.id=sst.vsl

[SQL] bug in 9.2.2 ? subquery accepts wrong column name : upd

2013-03-14 Thread Achilleas Mantzios
dynacom=# SELECT DISTINCT ON (qry.setid) qry.setid, qry.arragg[1:2] FROM (select distinct sst.setid,(array_agg(vsl.name) OVER (PARTITION BY sst.setid ORDER BY character_length(vsl.name))) as arragg FROM sissets sst, vessels vsl WHERE vsl.id=sst.vslid ORDER BY sst.setid) as qry