Proc*C/C++ 8.1.5 Select Array of Struct Problem

From: Rudi Ernst <news_at_rudi-ernst.de>
Date: Mon, 27 Sep 1999 20:54:53 GMT
Message-ID: <37efd51e.3403944_at_news.cis.dfn.de>



Hello all,

in my current project I'm using Proc*C/C++ 8.1.5 and Visual C++ 6.0 SP3 to select records from an Oracle 8i Database.

I have a simple program that works well with Proc*C/C++ 8.0.3 and an Oracle 8.0 database. It does a Cursor-SELECT of some records into an array of structs.

Here's some sample source code:

EXEC SQL BEGIN DECLARE SECTION;
struct TIMESLOT
{

	double Timeslot_Id;
	double Month_Id;
	double Week_Id;
	double Day_Id;
	double Hour_Id;

} Timeslot [1000];
EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE c CURSOR FOR

   SELECT Timeslot_Id, Month_Id, Week_Id, Day_Id, Hour_Id FROM    Tim_L_Timeslot ORDER BY 1;                 

EXEC SQL OPEN c;
EXEC SQL WHENEVER SQLERROR DO sql_error(); EXEC SQL WHENEVER NOT FOUND DO BREAK;          int num_ret = 0;
while (1)
{

	EXEC SQL FETCH c INTO :Timeslot;
	num_ret = sqlca.sqlerrd[2];
	printf ("%d rows selected (%lf).\n", sqlca.sqlerrd [2],
                           Timeslot [99].Timeslot_Id);
}

// process remaining rows from last fetch, if any. if ((sqlca.sqlerrd[2] - num_ret) > 0)

	printf ("%d rows selected (%lf).\n", sqlca.sqlerrd [2], 
	Timeslot [sqlca.sqlerrd[2] - num_ret - 1].Timeslot_Id);

printf ("%d rows selected.\n", sqlca.sqlerrd [2]); EXEC SQL CLOSE c;
EXEC SQL COMMIT WORK;
}

Under the Oracle 8i environment it's not working at all. If the Dimension of Timeslot is = 100 it loops and returns always the first 100 rows. If the Dimension of Timeslot is >100 it runs into an access violation in an Oracle-DLL.

Is this a known problem or am I doing something wrong?

Thanks for any help

Rudi from Munich Received on Mon Sep 27 1999 - 22:54:53 CEST

Original text of this message