X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 56E23475843 for ; Tue, 11 Feb 2003 17:26:51 -0500 (EST) Received: from luckydigital.com (www.luckydigital.com [203.109.157.4]) by postgresql.org (Postfix) with ESMTP id 1F4D6474E5C for ; Tue, 11 Feb 2003 17:26:50 -0500 (EST) Received: from jax (203-109-198-1.akl.ihugultra.co.nz [203.109.198.1]) by luckydigital.com (8.11.6/8.10.0) with SMTP id h1BMQoC25850 for ; Wed, 12 Feb 2003 11:26:50 +1300 Message-ID: <00f201c2d21c$aa14c3c0$c900a8c0@jax> From: "James Cooper" To: "sql" Subject: anal about my syntax Date: Wed, 12 Feb 2003 11:26:47 +1300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00EF_01C2D289.A0DA2A80" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/223 X-Sequence-Number: 11621 This is a multi-part message in MIME format. ------=_NextPart_000_00EF_01C2D289.A0DA2A80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello All=20 I was looking at this plpgsql function:=20 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; It works fine - I was just wondering if you can: 1. execute this sql without a loop being used as its not required. 2. could this be a straight SQL function instead( I dont think you can appe= nd strings together in SQL functions ) ------=_NextPart_000_00EF_01C2D289.A0DA2A80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello All
 
I was looking at this plpgsql=20 function: 
FOR rec IN EXECUTE
''sel= ect=20 count(person_id) as total from person where person_email like '''''' || $1 = ||=20 ''%'''' and person_id IN
(
select cp.person_id from cluster_person c= p,=20 cluster c where cp.cluster_id =3D c.cluster_id and c.c_id =3D '' || $2 || '= 'group by=20 cp.person_id
) ''
LOOP
tot =3D rec.total;
END=20 LOOP;
 
It works fine - I was = just=20 wondering if you can:
1. execute this sql without= a loop=20 being used as its not required.
2. could this be a straight= SQL=20 function instead( I dont think you can append strings together  in SQL= =20 functions )
 
 

 

------=_NextPart_000_00EF_01C2D289.A0DA2A80--