Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D78B2632754 for ; Mon, 21 Jun 2010 18:45:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 82948-06 for ; Mon, 21 Jun 2010 21:45:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 9E52C6325DA for ; Mon, 21 Jun 2010 18:45:11 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OQoni-0001p8-Gl for pgsql-sql@postgresql.org; Mon, 21 Jun 2010 23:45:06 +0200 Received: from e177123166.adsl.alicedsl.de ([85.177.123.166]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Jun 2010 23:45:06 +0200 Received: from tim by e177123166.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Jun 2010 23:45:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Re: error on line 1 trying to execute a script using psql Date: Mon, 21 Jun 2010 21:44:56 +0000 Organization: Lines: 35 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: e177123166.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:VGub5GudXVQ5qNTgmOFn2ep4Uxc= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/66 X-Sequence-Number: 34257 Steven Dahlin wrote: > I am attempting to generate a temporary function to execute some dml with > the following script: > create or replace function setuplicense() returns integer as $$ > declare > hwcustid integer := 0; > retval integer := 0; > begin > insert into license.customer > ( customer_id ) values ( hwcustid ); > commit; > return retval; > end; > $$ > LANGUAGE plpgsql; > select setuplicense(); > When running this with psql I get the following: > Error: syntax error at or near "create" > Does anyone have a suggestion as to what is causing this? Your editor prepends the file with a byte-order mark ("BOM") that PostgreSQL chokes on (bug #5398). This will be fixed in 9.0 (cf. ); until then you either have to configure your editor not to save the BOM or chop off the first three bytes yourself (with tail, sed, Perl & Co.). Tim