X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F3B6E475BA1 for ; Tue, 11 Feb 2003 20:10:26 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 61A22475AFA for ; Tue, 11 Feb 2003 20:10:26 -0500 (EST) Received: from [216.135.165.74] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 4.0.2) with HTTP id 2835260; Tue, 11 Feb 2003 17:10:35 -0800 From: "Josh Berkus" Subject: Re: anal about my syntax To: "James Cooper" , "sql" X-Mailer: CommuniGate Pro Web Mailer v.4.0.2 Date: Tue, 11 Feb 2003 17:10:35 -0800 Message-ID: In-Reply-To: <00f201c2d21c$aa14c3c0$c900a8c0@jax> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/229 X-Sequence-Number: 11627 James, > FOR rec IN EXECUTE > ''select count(person_id) as total from person where person_email > like '''''' || $1 || ''%'''' and person_id IN=20 > ( > select cp.person_id from cluster_person cp, cluster c where > cp.cluster_id =3D c.cluster_id and c.c_id =3D '' || $2 || ''group by > cp.person_id > ) '' > LOOP > tot =3D rec.total; > END LOOP; >=20 > It works fine - I was just wondering if you can: > 1. execute this sql without a loop being used as its not required. Not as written, no. > 2. could this be a straight SQL function instead( I dont think you > can append strings together in SQL functions ) Yes, it could. If I have time later, I'll draft you an example. -Josh