Re: Help requd in writing functions in C and using in Postgres

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Help requd in writing functions in C and using in Postgres
Дата
Msg-id 20060620165810.GA67893@winnie.fuhr.org
обсуждение исходный текст
Ответ на Help requd in writing functions in C and using in Postgres  ("Jasbinder Bali" <jsbali@gmail.com>)
Ответы Re: Help requd in writing functions in C and using in Postgres  ("Jasbinder Bali" <jsbali@gmail.com>)
Список pgsql-general
[Please copy the mailing list on replies so others can participate
in and learn from the discussion.]

On Tue, Jun 20, 2006 at 11:39:03AM -0400, Jasbinder Bali wrote:
> Well, as in normal Sql server or oracle Stored procedures, you write a
> procedure in the database server and some middle tier would invoke it.
> Now here what is the concept of server side or client side function in
> postres if i just have to create a function in C and then would like my
> Stored procedure to invoke it. Also all the DB related activities like
> select, delete, update should be taken care of by the C function itself.

It sounds like you want to write a server-side function that a
client application or another server-side function could invoke
with SELECT do_stuff() (or PERFORM do_stuff() in PL/pgSQL).  You
can do that in C, but unless you need the kind of low-level
functionality that only C can provide then you'd probably be better
off using a higher level server-side language like PL/pgSQL, PL/Perl,
PL/Python, PL/Tcl, PL/Ruby, PL/Java, PL/R, etc.

Functions in PostgreSQL aren't the same as stored procedures in
some other DBMSs.  For example, a function can't start or end a
transaction since it's already being executed in the context of a
transaction, although in 8.0 and later a function can do partial
rollbacks via exception handling.  However, a function could connect
to the database via dblink, Perl DBI, etc., and then do anything
that an ordinary client could do.

--
Michael Fuhr

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

Предыдущее
От: "Worky Workerson"
Дата:
Сообщение: Exporting data from view
Следующее
От: "Aaron Koning"
Дата:
Сообщение: Re: Exporting data from view