X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0F19356808 for ; Tue, 15 Mar 2005 03:38:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67585-10 for ; Tue, 15 Mar 2005 03:38:03 +0000 (GMT) Received: from titan.open-networks.net (dsl-202-173-176-254.qld.westnet.com.au [202.173.176.254]) by svr1.postgresql.org (Postfix) with ESMTP id 9F53C5680A for ; Tue, 15 Mar 2005 03:37:59 +0000 (GMT) Received: from [192.168.1.200] (unknown [192.168.1.1]) by titan.open-networks.net (Postfix) with ESMTP id 4A0D2A2E; Tue, 15 Mar 2005 13:38:01 +1000 (EST) Message-ID: <42365898.3020904@open-networks.net> Date: Tue, 15 Mar 2005 13:38:00 +1000 From: Timothy Smith User-Agent: Mozilla Thunderbird 0.8 (X11/20041023) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Michael Fuhr , pgsql-sql@postgresql.org Subject: Re: postgresql 8.01, plpgsql References: <42363BD1.6090405@open-networks.net> <20050315024104.GA59736@winnie.fuhr.org> In-Reply-To: <20050315024104.GA59736@winnie.fuhr.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.782 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, URIBL_SBL X-Spam-Level: X-Archive-Number: 200503/205 X-Sequence-Number: 20684 Michael Fuhr wrote: >On Tue, Mar 15, 2005 at 11:35:13AM +1000, Timothy Smith wrote: > > > >>i have the following function in plpgsql giving stynax errors all over >>the place. >> >> > >When I load the function you posted I get this: > >test=> \i foo.sql >psql:foo.sql:87: ERROR: syntax error at or near "END" at character 2851 >psql:foo.sql:87: LINE 83: END; >psql:foo.sql:87: ^ > >If I add a semicolon to the NULL statement in the exception handler >then it loads successfully. > > > >>one thing to note is i followed this example >>http://www.zigo.dhs.org/postgresql/#insert_or_update and it gives the >>same errors. >> >> > >I get no errors loading the example in the "Insert or Update" section >of that page. > > > >>"ERROR: unterminated dollar-quoted string at or near "$$ >>BEGIN >>LOOP" >> >> > >This looks like the parser is reaching EOF before the end of the >function body. How are you loading the function? I usually store code >in a file and use "psql -f filename" from the shell or "\i filename" >from the psql prompt. If you're not already doing that, what happens >when you try it? > > > ok i tried loading it from a file like you suggested and this is what i got for MY function \i /home/timothy/function psql:/home/timothy/function:35: ERROR: unterminated dollar-quoted string at or near "$$ BEGIN LOOP UPDATE daily_takings SET till_name = TillName, tape = Tape, cash = Cash, promo_manager = GM, venue_manager = VenueManager, asst_manager = AsstManager, bar_manager = BarManager, pr_cards = PRCards, other_promo = otherPromo, functions = Functions, accounts = Accounts, spill = Spill, o_rings = Orings, variance = Variance WHERE id = ID AND till_name = TillName;" at character 604 psql:/home/timothy/function:37: ERROR: syntax error at or near "IF" at character 3 psql:/home/timothy/function:38: ERROR: syntax error at or near "IF" at character 7 psql:/home/timothy/function:70: ERROR: syntax error at or near "INSERT" at character 13 psql:/home/timothy/function:71: ERROR: syntax error at or near "RETURN" at character 4 psql:/home/timothy/function:74: ERROR: syntax error at or near "EXCEPTION" at character 3 psql:/home/timothy/function:75: ERROR: syntax error at or near "LOOP" at character 6 psql:/home/timothy/function:76: WARNING: there is no transaction in progress COMMIT psql:/home/timothy/function:78: ERROR: unterminated dollar-quoted string at or near "$$ LANGUAGE plpgsql;" at character 1 and similarly for the example i got \i /home/timothy/function psql:/home/timothy/function:1: ERROR: unterminated dollar-quoted string at or near "$$ BEGIN LOOP UPDATE db SET b = data WHERE a = key;" at character 63 psql:/home/timothy/function:1: ERROR: syntax error at or near "IF" at character 2 psql:/home/timothy/function:1: ERROR: syntax error at or near "IF" at character 6 psql:/home/timothy/function:2: ERROR: syntax error at or near "INSERT" at character 8 psql:/home/timothy/function:2: ERROR: syntax error at or near "RETURN" at character 2 psql:/home/timothy/function:2: ERROR: syntax error at or near "EXCEPTION" at character 2