Re: PL/SQL: function call like $1($2)

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: PL/SQL: function call like $1($2)
Дата
Msg-id b42b73150610090732n6e229379vf6d3e12f9ad89e2d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PL/SQL: function call like $1($2)  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
On 10/9/06, Michael Fuhr <mike@fuhr.org> wrote:
> On Sun, Oct 08, 2006 at 05:49:11PM +0200, Jean-Gerard Pailloncy wrote:
> > I try EXECUTE f || ' ( ' || p || ' );' INTO res
> > But is does not work too.
> > There is no function to convert double precision[] to text.
>
> You could use the types' input and output functions or perhaps
> array_to_string().
>
> stmt := 'SELECT ' || quote_ident(f) || '(' || quote_literal(textin(array_out(p))) || ')';
> EXECUTE stmt INTO res;

thinking about this some more, it looks like the basic issue is
passing in function to operate over a defined type, sort of like a sql
closure.  This can be rigged in dynamic sql but this has couple
problems.  Complex types are a pain (record types are even worse) and
dynamic sql feels like a kludge anyhow.  Here is maybe another
solution:

you can make a make an oid from a string:
esilo=# create function foo() returns void as $$ ; $$ language sql;
CREATE FUNCTION
esilo=# select 'foo()'::regprocedure::oid;
  oid
--------
 300009
(1 row)

whierle the is no way to call a function via its oid in pl/pgsql, it
is fairly trivial from C and somewhat generic using
OidFunctionCall1(): (or 2, etc)

http://www.nabble.com/improvise-callbacks-in-plpgsql-tf476925.html#a1299810

I have tested this approach, and it works!

merlin

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: column privileges
Следующее
От: "George Pavlov"
Дата:
Сообщение: postgres query log analysis?