Re: Stored Procedures

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Stored Procedures
Дата
Msg-id web-1452641@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Stored Procedures  (Wendy Powley <wendy@cs.queensu.ca>)
Список pgsql-novice
Wendy,

> Here I'm referring to a "C struct" ... a data structure containing
> several values.  For instance, I might have a struct defined as
> followed:
>
>   struct person {
>      char name[10],
>       char address[30],
>        int  age };
>
> containing the name, address & age of a particular person.

Ah.  I see what you're attempting.

I'm not sure that you want to operate through functions at all.  There
is a very hefty C library for direct Postgres interaction.  You can
look it up in the online docs, or buy a book (such as Wrox Press's
Postgres book) which covers C + Postgresql programming.

That's as much as I know ... I'm a SQL jockey, and don't do C.

> What do you mean by a record here?  Sorry, I'm new to the postgres
> terminology (although quickly learning!!!).

A RECORD is a data type that holds field data for one to several
fields, and performs ... in PL/pgSQL functions ... a lot like the
Struct you mention.  However, a RECORD must be keyed off a query, as
follows:

DECLARE
    my_rec RECORD;
BEGIN
SELECT id, type INTO my_rec
FROM table1 WHERE id = $1;
IF my_rec.type = 'press contact' THEN

etc.

See the PL/pgSQL documentation (Under "Procedural Langauges" where
you'll find information on C functions as well) for more information
about this.

-Josh Berkus




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

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: Stored Procedures
Следующее
От: "Joshua Moore-Oliva"
Дата:
Сообщение: Functions replicating stored procedures