Re: error on line 1 trying to execute a script using psql - Mailing list pgsql-sql

From Tim Landscheidt
Subject Re: error on line 1 trying to execute a script using psql
Date
Msg-id m3ocf42h7r.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to error on line 1 trying to execute a script using psql  (Steven Dahlin <pgdb.sldahlin@gmail.com>)
Responses Re: error on line 1 trying to execute a script using psql  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
List pgsql-sql
Steven Dahlin <pgdb.sldahlin@gmail.com> 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.
<URI:http://developer.postgresql.org/pgdocs/postgres/release-9-0.html#AEN99331>);
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



pgsql-sql by date:

Previous
From: Brian Sherwood
Date:
Subject: Re: running scripts like oracle sqlplus
Next
From: "A. Kretschmer"
Date:
Subject: Re: error on line 1 trying to execute a script using psql