Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 7BE956326FD for ; Tue, 22 Jun 2010 02:08:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 50668-07 for ; Tue, 22 Jun 2010 05:08:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by mail.postgresql.org (Postfix) with ESMTP id 4FE776325DA for ; Tue, 22 Jun 2010 02:08:06 -0300 (ADT) Received: from webserv.wug.de ([194.25.154.138]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0Mczwc-1Oj0pb04DC-00Hl7s; Tue, 22 Jun 2010 07:08:05 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1OQviO-0003eI-00 for pgsql-sql@postgresql.org; Tue, 22 Jun 2010 07:08:04 +0200 Date: Tue, 22 Jun 2010 07:08:04 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: error on line 1 trying to execute a script using psql Message-ID: <20100622050803.GA13356@a-kretschmer.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1/974WEengHiHVDB0Cs3pKvIit+i/xAy0xiMwv AncsHvORWZ0PCa6ulwGPlf3t4ScsFS/Kf8GHGR1Kt15nRGjycO qvy58rrJ4JIoeZspayJ2w== X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.81 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001, T_FRT_CONTACT=0.01 X-Spam-Level: X-Archive-Number: 201006/67 X-Sequence-Number: 34258 In response to Tim Landscheidt : > 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.). Additional error: you can't do a COMMIT inside a function. Regards, Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99