Re: using Array of struct in Pro*C++
Date: Fri, 9 Mar 2001 13:26:24 -0500
Message-ID: <98b7ai$mir$1_at_nntp.sita.int>
[Quoted] Hi, all:
I read Oracle white paper and some paper on the internet. They said Oracle V8.0.4 supports struct array for insert/query and pointer but I have some problem to implement it (I am using V8.0.4).
E.g.
EXEC SQL BEGIN DECLARE SECTION;
typedef struct TT {
char name[10];
int id } T;
T t1[2];
int *_id;
EXEC SQL END DECLARE SECTION;
void main()
{
_id = malloc(sizeof(int )*2);
int ii;
EXEC SQL SELECT id INTO :_id FROM test; /* suppose test table just has two
rows for id */
/* it doesn't work. error msg: select too many rows. I believe Pro*c still
think *_id = _id (one row) */
strcpy(t1[0].name,"Jordan");
[Quoted] t1[0].id = 12;
strcpy(t1[1].name, "Mason");
t1[1].id = 14;
EXEC SQL INSERT test(name, id) VALUES (:t1);
/* it doesn't compile. Error msg: using array of structs require that the
structs be named */
[Quoted] /* it works following but it is NOT really I want it.*/
for(ii = 0;ii<2;ii++)
{
EXEC SQL INSERT test(name, id) values(:t1[ii]);
}
EXEC SQL SELECT * INTO :t1 FROM TEST;
/* it doesn't compile. Error msg:using array of structs require that the
structs be named */
}
Could I declare point of struct and dynamically allocate this struct and then use it for insert and query?
[Quoted] Thanks in advance!
Kevin Gao Received on Fri Mar 09 2001 - 19:26:24 CET