Re: Stored Procedures

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Wendy Powley <wendy(at)cs(dot)queensu(dot)ca>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Stored Procedures
Date: 2002-05-07 18:15:47
Message-ID: web-1452641@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-novice by date

  From Date Subject
Next Message Joshua Moore-Oliva 2002-05-07 23:30:40 Functions replicating stored procedures
Previous Message Josh Berkus 2002-05-07 17:38:41 Re: Problems with psql : ERROR : pg_user: permission