pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feederror on line 1 trying to execute a script using psql
3+ messages / 3 participants
[nested] [flat]
* error on line 1 trying to execute a script using psql
@ 2010-06-20 21:53 Steven Dahlin <pgdb.sldahlin@gmail.com>
2010-06-21 21:44 ` Re: error on line 1 trying to execute a script using psql Tim Landscheidt <tim@tim-landscheidt.de>
0 siblings, 1 reply; 3+ messages in thread
From: Steven Dahlin @ 2010-06-20 21:53 UTC (permalink / raw)
To: pgsql-sql
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?
Thanks
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: error on line 1 trying to execute a script using psql
2010-06-20 21:53 error on line 1 trying to execute a script using psql Steven Dahlin <pgdb.sldahlin@gmail.com>
@ 2010-06-21 21:44 ` Tim Landscheidt <tim@tim-landscheidt.de>
2010-06-22 05:08 ` Re: error on line 1 trying to execute a script using psql A. Kretschmer <andreas.kretschmer@schollglas.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tim Landscheidt @ 2010-06-21 21:44 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: error on line 1 trying to execute a script using psql
2010-06-20 21:53 error on line 1 trying to execute a script using psql Steven Dahlin <pgdb.sldahlin@gmail.com>
2010-06-21 21:44 ` Re: error on line 1 trying to execute a script using psql Tim Landscheidt <tim@tim-landscheidt.de>
@ 2010-06-22 05:08 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
0 siblings, 0 replies; 3+ messages in thread
From: A. Kretschmer @ 2010-06-22 05:08 UTC (permalink / raw)
To: pgsql-sql
In response to Tim Landscheidt :
> 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.).
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2010-06-22 05:08 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-06-20 21:53 error on line 1 trying to execute a script using psql Steven Dahlin <pgdb.sldahlin@gmail.com>
2010-06-21 21:44 ` Tim Landscheidt <tim@tim-landscheidt.de>
2010-06-22 05:08 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox