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 1E8A2D1BACD for ; Wed, 21 Apr 2004 05:49:34 -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 50004-10 for ; Wed, 21 Apr 2004 05:49:34 -0300 (ADT) Received: from cyber12.e-insites.com (ns10.nic-reg-dns.com [66.206.10.2]) by svr1.postgresql.org (Postfix) with ESMTP id A8F3FD1BABF for ; Wed, 21 Apr 2004 05:49:31 -0300 (ADT) Received: from server2k ([61.11.69.26]) by cyber12.e-insites.com with MailEnable ESMTP; Wed, 21 Apr 2004 01:49:32 -0700 Received: from 192.168.50.51 by server2k ([192.168.50.102] running VPOP3) with SMTP; Wed, 21 Apr 2004 14:27:54 +0530 X-MSReally-From: denis@coralindia.com Message-ID: <005801c4277c$ecddbfc0$3332a8c0@DENIS> From: denis@coralindia.com To: "David B" , References: Subject: Re: Syntax for cmd to EXEC...how many quotes? Date: Wed, 21 Apr 2004 14:14:56 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Server: VPOP3 V1.5.0 - Registered X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200404/281 X-Sequence-Number: 17656 Try (to solve string terminating error ): sql_string := ''INSERT INTO temp_table ( view_name, row_count ) SELECT '' || r_rec.viewname || '', count(*) FROM '' || r_rec.viewname || '' ; '' ; BUT, you will be needing to put view_name in Quote too... try it yourself... HTH Denis ----- Original Message ----- From: David B To: Sent: Wednesday, April 21, 2004 4:54 AM Subject: [SQL] Syntax for cmd to EXEC...how many quotes? > 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 > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org