Re: Quotes and spaces

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Quotes and spaces
Дата
Msg-id Pine.BSF.4.21.0110051630090.63466-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Quotes and spaces  (Oleg Lebedev <olebedev@waterford.org>)
Список pgsql-sql
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 '
DECLAREquery text;rec record;
BEGINquery := ''SELECT a || '''' '''' || a as bar from aa;'';RAISE NOTICE ''%'', query;FOR rec in EXECUTE query LOOP
returnrec.bar;END LOOP;
 
END;'
language 'plpgsql';
select fgn('f');




В списке pgsql-sql по дате отправления:

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: Quotes and spaces
Следующее
От: Oleg Lebedev
Дата:
Сообщение: Re: Quotes and spaces