Clarified Question

Поиск
Список
Период
Сортировка
От Kyle Bateman
Тема Clarified Question
Дата
Msg-id 392C5B5C.64CCAA78@actarg.com
обсуждение исходный текст
Список pgsql-sql
 
How can I create a function that will take in two variables and return
an integer, when one of the variables is the tablename ?!

I have tried :

                create function tst_func(text, varchar(16))
                as
                'BEGIN
                        result=select max(history_id)+1 from $1
                                where client_id = $2;
                        return result;
                 END;'
 

This kind of thing does work in pltcl but AFAIK you can't specify a table name with a parameter in plpgsql.  This may give you the idea:

create function myfunc(text,text) returns result as '
    set res [spi_exec "select f1 from $1 where f2 = \'$2\']
    return $res
    ' language 'pltcl';
 

Вложения

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

Предыдущее
От: Joseph Shraibman
Дата:
Сообщение: possible bug with group by?
Следующее
От: JanWieck@t-online.de (Jan Wieck)
Дата:
Сообщение: Re: Why is PostgreSQL 7.0 SQL semantics different from Oracle's?