X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DCE4ED1EF22 for ; Tue, 20 Apr 2004 20:24:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 50501-07 for ; Tue, 20 Apr 2004 20:24:40 -0300 (ADT) Received: from srv02.shieldhost.com (srv02.shieldhost.com [66.98.168.13]) by svr1.postgresql.org (Postfix) with ESMTP id D997AD1F013 for ; Tue, 20 Apr 2004 20:24:37 -0300 (ADT) Received: from DellLaptopDG ([64.62.211.38]) (authenticated (0 bits)) by srv02.shieldhost.com (8.11.6/8.11.6) with ESMTP id i3KNS6b05216 for ; Tue, 20 Apr 2004 18:28:06 -0500 From: "David B" To: Subject: Syntax for cmd to EXEC...how many quotes? Date: Tue, 20 Apr 2004 16:24:32 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/193 X-Sequence-Number: 17568 Folks, This is driving me crazy...I'm sure it's possible but that I am getting the #quotes wrong in some way... I keep getting unterminated string errors...now matter how many quotes I use. I have a FN that I want to loop through all views and populate a table with a count(*) from each views. To do it I'm doing a LOOP around all views...something like: FOR r_rec IN SELECT viewname from pg_views LOOP sql_string := 'INSERT INTO temp_table ( view_name, row_count ) SELECT ''' || r_rec.viewname || ''', count(*) FROM ' || r_rec.viewname || ' ; ' ; EXEC sql_string ; END LOOP ; END ; Building that sql_string is the problem. Any thoughts folks? -D --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.648 / Virus Database: 415 - Release Date: 3/31/2004