Re: Proc: fetch into C structure

From: Rob Allan <rob.e.allan_at_hydro.on.ca>
Date: 1996/01/28
Message-ID: <310B9CC3.178C_at_hydro.on.ca>#1/1


Alexander L. Makovsky wrote:
>
> Hello All !
>
> Recently I saw a message about
> that in PROC 2.0 it is possible to fetch
> all or several fields of the table into
> a C structure, and moreover, fetch records
> into the array of such structures.
> I know that it's possible to declare
> pointers to structure fields and use
> them but I cannot use this method with
> arrays because arrays of pointers are not
> allowed in DECLARE section.
> That message and oracle manual :) says.
> that there is another way to do it,
> but I was not able to find any further
> information. It would be nice if someone
> post an example of this method. Thanks.
>
> Konstantin Kivi.
You can't select into an array of structures, you can select into a structure of arrays.
For e.g., if you want to get a bunch of rows with: id,name,cost :

typedef struct {
int id[20];
char name[10][20];
float cost[20];
} my_row;

void simple_test(my_row* mrow)
{
/*get the channel properties for the unit */

    EXEC SQL SELECT
        id,name,cost,
    INTO :my_row
    FROM some_column
    WHERE cost > 20
    ORDER BY id;
    return;
}

This should work ok, unless the select returns > 20 rows.

Hope this helps,

-- 
Rob Allan                       |  rob.e.allan_at_hydro.on.ca
Ontario Hydro                   |  Tel. (416) 592 4195
Toronto, Ontario, Canada        |  Fax  (416) 592 4966
Received on Sun Jan 28 1996 - 00:00:00 CET

Original text of this message