From: | Oleg Lebedev <olebedev(at)waterford(dot)org> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Quotes and spaces |
Date: | 2001-10-05 23:54:11 |
Message-ID: | 3BBE4822.B69C2B0E@waterford.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
I just upgraded to 7.1 and the query works for me now.
thanks,
Oleg
Stephan Szabo wrote:
> On Fri, 5 Oct 2001, Oleg Lebedev wrote:
>
> > Hi,
> > I looked through PL/pgSQL tutorial, but I can't get quotes and spaces to
> > work in queries executed from Pl/pgSQl. Here is an example:
> >
> > create procedure get_name(varchar)
> > ...
> > BEGIN
> > query := ''SELECT first_name || '''' '''' || last_name FROM user'';
> > EXECUTE query;
> > ...
> > END;
> > ...
> >
> > Basically I want to get full name, i.e. first name separated with space from
> > the last name. If I follow the PL/pgSQL manual as shown above, I get parse
> > error.
> > What am I doing wrong?
>
> Odd, a script like the following works for me on both 7.1 and 7.2devel:
>
> drop table aa;
> drop function fgn(varchar);
> create table aa(a varchar);
> insert into aa values ('d');
> create function fgn(varchar) returns text as '
> DECLARE
> query text;
> rec record;
> BEGIN
> query := ''SELECT a || '''' '''' || a as bar from aa;'';
> RAISE NOTICE ''%'', query;
> FOR rec in EXECUTE query LOOP
> return rec.bar;
> END LOOP;
> END;'
> language 'plpgsql';
> select fgn('f');
From | Date | Subject | |
---|---|---|---|
Next Message | max_conf | 2001-10-06 07:24:11 | returned multiple data from function |
Previous Message | Stephan Szabo | 2001-10-05 23:31:27 | Re: Quotes and spaces |
From | Date | Subject | |
---|---|---|---|
Next Message | Masaru Sugawara | 2001-10-06 09:54:21 | Re: challenging query |
Previous Message | Stephan Szabo | 2001-10-05 23:31:27 | Re: Quotes and spaces |