Re: ProC and selecting into arrayed structures?
Date: 1996/04/23
Message-ID: <317DB568.196F_at_realworld.com>#1/1
Tom,
How's it going? The manual says you can't do arrays of structures. (and I haven't been able to get it to either) I haven't had a problem selecting into structures of arrays however. See the following bit of code:
#define ARRAY_SIZE 10
struct
{
int animal_id[ARRAY_SIZE];
char animal_name[ARRAY_SIZE][30];
int weight[ARRAY_SIZE]; } animal_rec;
...
Connect etc....
...
EXEC SQL WHENEVER SQLERROR DO sql_error(); EXEC SQL SELECT animal_id, animal_name, nvl(weight,0)
INTO :animal_rec FROM animal;
for (i=0; i<sqlca.sqlerrd[2]; i++)
printf("id: %d name: %s weight: %d\n",animal_rec.animal_id[i],
animal_rec.animal_name[i], animal_rec.weight[i]);
...
Hope things are going well for you.
Kerry Osborne
Database Consultants, Inc.
osborne_at_realworld.com
Tom Armistead wrote:
>
> Can anyone help me with this? I've written some ProC code that
> selects into structures. (i.e. cursor and then 'fetch for :number').
> I'm having problems getting arrayed strctures to work. I've tried
> making the structure an array (i.e. struct Record rec[100]). The
> fetch works, but I get junk back from Oracle (i.e. the structure has
> bad data in it). I also tried making each field in the structure an
> array (i.e. struct Record { int f1[100]; int f2[100; } rec). The
> fetch stiff works (i.e. sqlcode returns 0 or 1403), but I stiff have
> junk in the data returned from Oracle. I'm using ProC 2.?.
>
> Any suggestions?
>
> Much thanks,
> Tom
> --
> Tom Armistead Software Services
> tarm_at_cris.com Garland, TX 75040
Received on Tue Apr 23 1996 - 00:00:00 CEST