xmlelement name

Поиск
Список
Период
Сортировка
От Ben Morgan
Тема xmlelement name
Дата
Msg-id CA+pT-SVS1TCm+=BFiU8ZXUCtutqEPuNZrSLKLMPw9ZFVTAobaA@mail.gmail.com
обсуждение исходный текст
Ответы Re: xmlelement name  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-sql
Hi,

I'm trying to write a function that will take a name as a text value,
and return an XML element with that name as name, like so:

create function xpercent(nam text, val int) returns xml as $$   begin       return ( select xmlelement(name nam,
concat(val::text,'%')) );   end; 
$$ language plpgsql;

But when I call the function, nam is used as the name instead of what
the parameter nam contains:

select xpercent('hello', 4);  xpercent
---------------<nam>4%</nam>
(1 row)

How can I get this to work so I get <hello>4%</hello instead?
Thanks!

–Ben



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

Предыдущее
От: Barbara Woolums
Дата:
Сообщение: 3/9/2013 2:45:30 PM
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: xmlelement name