execute in pl/pgsql

Lists: pgsql-general
From: Dino Vliet <dino_vliet(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: execute in pl/pgsql
Date: 2006-09-10 11:46:46
Message-ID: 20060910114646.64617.qmail@web51101.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

In my pl/pgsql procedure I have the following line:

execute 'copy cancella to ' || location || ' with
delimiter as \',\'';

Location is a string that gives the absolute pathname.

It's obvious what I'm aiming for, but this still gives
an error because of the two '' I'm missing around the
location var.

That's why I'm getting this error message:

NOTICE: location is hier
/usr/local/pgsql/data/plpgtrainin10.txt

ERROR: syntax error at or near "/" at character 18
QUERY: copy cancella to
/usr/local/pgsql/data/plpgtrainin10.txt with delimiter
as ','
CONTEXT: PL/pgSQL function "perform" line 16 at
execute statement

How can I solve it? I've tried a few things but keep
getting this error.

Thanks

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dino Vliet <dino_vliet(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: execute in pl/pgsql
Date: 2006-09-10 14:55:00
Message-ID: 6883.1157900100@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Dino Vliet <dino_vliet(at)yahoo(dot)com> writes:
> In my pl/pgsql procedure I have the following line:

> execute 'copy cancella to ' || location || ' with
> delimiter as \',\'';

quote_literal(location) would work much better and more safely.

regards, tom lane


From: Dino Vliet <dino_vliet(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: execute in pl/pgsql
Date: 2006-09-10 19:00:41
Message-ID: 20060910190041.54804.qmail@web51115.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Solved:-)
Thanks for your aanswer, now I can go further with
exploring pl/pgsql. Looks nice.

Brgds

--- Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Dino Vliet <dino_vliet(at)yahoo(dot)com> writes:
> > In my pl/pgsql procedure I have the following
> line:
>
> > execute 'copy cancella to ' || location || ' with
> > delimiter as \',\'';
>
> quote_literal(location) would work much better and
> more safely.
>
> regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will
> ignore your desire to
> choose an index scan if your joining column's
> datatypes do not
> match
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com