Re: Accessing Database Data from C Function
От | Michael Fuhr |
---|---|
Тема | Re: Accessing Database Data from C Function |
Дата | |
Msg-id | 20060809023314.GA14667@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Accessing Database Data from C Function (jeffrey.bigham@gmail.com) |
Ответы |
Re: Accessing Database Data from C Function
|
Список | pgsql-general |
On Tue, Aug 08, 2006 at 12:16:18PM -0700, jeffrey.bigham@gmail.com wrote: > I'd like to write a C Function for Postgresql that can access data in > the database, use that to conduct additional queries to find more > information in the database and eventually return a result. I > currently have the functionality I want implemented as php/C programs > that first connect to the database, do the processing and then > disconnect, but I want to make it what I think is called a "stored > procedure" in other databases. It seems odd that I would write a C > program to be included in the database that connects to the localhost > - is that what I should do? Is that somehow more efficient than > running it as a separate process? Server-side functions written in C can use the Server Programming Interface (SPI) to query the database. http://www.postgresql.org/docs/8.1/interactive/spi.html Do you have a reason to use C instead of a higher-level language? Functions that are mostly queries are probably best done in SQL or PL/pgSQL, while text processing and some OS-level access (e.g., reading and writing files) can be done with PL/Perl, PL/Tcl, PL/Python, PL/Ruby, PL/R, etc. There's even a third-party PL/php if that's your preferred language: http://projects.commandprompt.com/public/plphp -- Michael Fuhr
В списке pgsql-general по дате отправления: