Re: Proc: fetch into C structure
Date: 1996/01/30
Message-ID: <4ejpnk$6uc_at_inet-nntp-gw-1.us.oracle.com>#1/1
In article <4eb9j9$hav_at_news.sovam.com>, amakovsk_at_sovam.com (Alexander L. Makovsky) writes:
|>
|> 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 are partially correct. As the Pro*C 2.0 and higher manuals document, you
can fetch directly into a structure. Something like:
struct {
char ename[10];
int empno;
} emp_struct;
/* Fetch one row */
EXEC SQL SELECT ename, empno
INTO :emp_struct
FROM emp;
However, you CANNOT fetch into an array of structures (as the Pro*C 2.0 and higher manuals also document). Therefore, this is ILLEGAL:
struct {
char ename[10];
int empno;
} emp_struct[100];
/* Fetch 100 rows - illegal */
EXEC SQL SELECT ename, empno
INTO :emp_struct
FROM emp;
But, you can fetch into a structure of arrays (not an array of structures);
struct {
char ename[10][100];
int empno[100];
} emp_struct;
/* Fetch 100 rows - legal */
EXEC SQL SELECT ename, empno
INTO :emp_struct
FROM emp;
Received on Tue Jan 30 1996 - 00:00:00 CET