X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 4202230EB67 for ; Fri, 20 Jun 2003 20:26:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 01506-02 for ; Fri, 20 Jun 2003 17:26:01 -0300 (ADT) Received: from pat.uio.no (pat.uio.no [129.240.130.16]) by svr1.postgresql.org (Postfix) with ESMTP id 09DAB30EB41 for ; Fri, 20 Jun 2003 17:26:01 -0300 (ADT) Received: from mail-mx2.uio.no ([129.240.10.30]) by pat.uio.no with esmtp (Exim 2.12 #7) id 19TSSO-0002N9-00 for pgsql-sql@postgresql.org; Fri, 20 Jun 2003 22:26:00 +0200 Received: from [129.240.130.19] (helo=miss.uio.no) by mail-mx2.uio.no with esmtp (Exim 4.14) id 19TSSL-0001Ly-BT for pgsql-sql@postgresql.org; Fri, 20 Jun 2003 22:25:57 +0200 Received: from snapp.uio.no ([129.240.130.64]) by miss.uio.no with esmtp (Exim 2.12 #7) id 19TSSL-0002rR-00 for pgsql-sql@postgresql.org; Fri, 20 Jun 2003 22:25:57 +0200 Received: from pk06.uio.no ([129.240.46.56] helo=PK-HPC-KNUTLE.tiscali.no) by snapp.uio.no with esmtp (Exim 2.12 #7) id 19TSSK-0000dD-00 for pgsql-sql@postgresql.org; Fri, 20 Jun 2003 22:25:56 +0200 Message-Id: <5.1.0.14.2.20030620214454.00c200e0@uio-pop.uio.no> X-Sender: knutle@uio-pop.uio.no X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 20 Jun 2003 22:24:07 +0200 To: pgsql-sql@postgresql.org From: "Knut P. Lehre" Subject: plpgsql, double quoted column names containing spaces/hyphens Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-MailScanner-Information: This message has been scanned for viruses/spam. Contact postmaster@uio.no if you have questions about this scanning. X-UiO-MailScanner: No virus found X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=MSG_ID_ADDED_BY_MTA_3 X-Spam-Level: * X-Archive-Number: 200306/238 X-Sequence-Number: 13996 Using pgsql 7.2.1 (PeerDirect beta4) on WinXP Prof SP1. Client: MS VStudio2003 C++ -> ADO -> ODBC 7.03.01.00. In plpgsql, I can access columns with a name containing capital letters by enclosing the name in double quotes: tbl."ColName" However, if the quoted name contains spaces or hyphens I get an error message. It is surprising that this does not work in plpgsql when it does with sql. Thus, the following line produces an error (unterminated ") in plpgsql: IF OLD."-person-initials" ... THEN However, I discovered that rewriting using EXECUTE does work: DECLARE curs1 refcursor; personinitials int4; ... OPEN curs1 FOR EXECUTE ''SELECT "-person-initials" AS pers FROM "''||TG_RELNAME||''" WHERE id=''||OLD.id; FETCH curs1 INTO personinitials; CLOSE curs1; IF personinitials ... THEN Could I have solved this problem in an easier way, by using some kind of escape codes in the example producing the error (IF OLD."-person-initials" ... THEN)? Thanks, KP