Hi all

I have a heap corruption problem in getting STL containers data through OCCI methods .
For instance if i do an assignment of this type

while(rs->next() )
			{

			SRecord r; '' struct object
			r.PDM_APPLICATION_NO= rs->getString(1);
			r.PDM_FIRST_NAME=rs->getString(2);; //Error Heap Corruption
			r.PDM_LAST_NAME= rs->getString(3);						
			r.PDM_F_FIRST_NAME= rs->getString(4);
			}

I use Visual C++8 (VS 2005)[Windows 32-bit] oracle 10.2.0.3.0

That's not enough information to solve your problem.

Hi all

I have a heap corruption problem in getting STL containers data through OCCI methods .
For instance if i do an assignment of this type

while(rs->next() )
{

SRecord r; '' struct object
r.PDM_APPLICATION_NO= rs->getString(1);
r.PDM_FIRST_NAME=rs->getString(2);; //Error Heap Corruption
r.PDM_LAST_NAME= rs->getString(3); 
r.PDM_F_FIRST_NAME= rs->getString(4);
}

I use Visual C++8 (VS 2005)[Windows 32-bit] oracle 10.2.0.3.0


I get information from oracle table 'sample'. In this table 11 fields and 100000 records. program run without error in release mode vs 2005. 12 thousand records are fatched and then Heap corruption problem message dispaly and exit from program.

More information please?..

#define WIN32COMMON


#include <iostream>
#include <Time.h>
#include <occi.h>
using namespace oracle::occi;
using namespace std;

struct SRecord
{

	string PDM_APPLICATION_NO; 
	string PDM_FIRST_NAME; 
	string PDM_LAST_NAME; 
	string PDM_F_FIRST_NAME; 
	string PDM_F_LAST_NAME; 
	string PDM_SPOUSE_NAME; 
	string PDM_DOB; 
	string PDM_ADD_LINE_1_RES; 
	string PDM_ADD_LINE_2_RES; 
	string PDM_ADD_LINE_3_RES; 
	string PDM_CITY_RES; 


};
int main()
{

	char tmpbuf[128];
	vector<SRecord> row1;

		try{ 
_strtime(tmpbuf);
cout<<endl<<" database open start"<<tmpbuf;

				Environment* env = Environment::createEnvironment(Environment::OBJECT); 
				Connection* conn = env->createConnection( "system", "dedupe","" ); 
_strtime(tmpbuf);
cout<<endl<<" database open end"<<tmpbuf;
			


				//string sqlQuery = "select * from timetest"; 

_strtime(tmpbuf);
cout<<endl<<" dynaset open start"<<tmpbuf;

				Statement* stmt = conn->createStatement("select * from timetest");
				ResultSet *rs = stmt->executeQuery();
_strtime(tmpbuf);
cout<<endl<<" dynaset open end"<<tmpbuf;

			
				
	_strtime(tmpbuf);

	cout<<endl<<"select Start Time "<<tmpbuf;
	//ResultSet::Status status;
	//while((status = rs->next()) == (ResultSet::DATA_AVAILABLE))

	int i=0;
	while(rs->next() )
			{


					SRecord r;

					r.PDM_APPLICATION_NO= rs->getString(1);
					r.PDM_FIRST_NAME= rs->getString(2);
					r.PDM_LAST_NAME= rs->getString(3);						//string str = d->rs->getString(2);
					r.PDM_F_FIRST_NAME= rs->getString(4);
					r.PDM_F_LAST_NAME= rs->getString(5); 					//	cout<<"ID   : "<<r.id;
					r.PDM_SPOUSE_NAME= rs->getString(6);					//	cout<<"   Name  : "<<r.name <<endl;
					r.PDM_DOB=rs->getString(7);

					r.PDM_ADD_LINE_1_RES= rs->getString(8);						//str=d->rs->getString(2);
					r.PDM_ADD_LINE_2_RES=rs->getString(9);						//cout<<str ;
					r.PDM_ADD_LINE_3_RES= rs->getString(10); 
					r.PDM_CITY_RES=rs->getString(11);


					row1.push_back(r);

			//	cout<<i++<<endl;
				
			}

	_strtime(tmpbuf);
cout<<endl<<" select End Time "<<tmpbuf<<endl;

	_strtime(tmpbuf);
	cout<<"Insert   Start Time "<<tmpbuf<<endl;

				
		string str1;
	
	//	vector<SRecord>::iterator i;
		stmt->setAutoCommit(true);
			//for (i = row1.begin(); i != row1.end(); i++)
			for( long iCtr=0 ; iCtr < row1.size()  ; iCtr++)
			{
					
				SRecord  &ObjRec1 =row1[iCtr];

				str1="INSERT INTO dest_timetest VALUES('" ;
				str1+= ObjRec1.PDM_APPLICATION_NO ;
				str1 +=	"','";
				str1 += ObjRec1.PDM_FIRST_NAME ;
				str1 += "','";
				str1 +=  ObjRec1.PDM_LAST_NAME;
				str1 +=  "','" ;
				str1 += ObjRec1.PDM_F_FIRST_NAME ;
				str1 += "','" ;
				str1 += ObjRec1.PDM_F_LAST_NAME ;
				str1 += "','" ;
				str1 += ObjRec1.PDM_SPOUSE_NAME ;
				str1 +=  "','" ;
				str1 += ObjRec1.PDM_DOB ;
				str1 += "','";
				str1 += ObjRec1.PDM_ADD_LINE_1_RES ;
				str1 += "','" ;
				str1 += ObjRec1.PDM_ADD_LINE_2_RES ;
				str1 += "','" ;
				str1 += ObjRec1.PDM_ADD_LINE_3_RES ;
				str1 +="','" ;
				str1 += ObjRec1.PDM_CITY_RES ;
				str1 +="' )";
	stmt = conn->createStatement(str1);
	stmt->execute();
conn->terminateStatement(stmt);	
stmt =conn->createStatement("commit");
stmt->execute();
conn->terminateStatement(stmt);	
			
			} 

			_strtime(tmpbuf);
			cout<<endl<<"End Time "<<tmpbuf<<endl;
		env->terminateConnection(conn);
	
					Environment::terminateEnvironment(env);
	
					cout << "Closing connection." << endl;
	
	
				}
				catch(SQLException ex)
				{
					 //cout<<"Exception thrown for createConnection"<<endl;
					cout<<"Error number: "<<  ex.getErrorCode() << endl;
					cout<<ex.getMessage() << endl;
				}
	
		getchar();
	return 0;

this is my code i run this code in vs 2005 using oracle 10g. this code run but when read data from table that time some record read and dispaly message Heap corruption problem .

please help me

when we install oracle many dlls are copied to home direcory of oracle.
OCCI( oracle call for c++ interface) provides the means of comunication with the oracle through c++. It has 4 dlls to provide access to oracle database. like kpucb.dll,oci.dll,ociw32.dll,oraocci10.dll

i have installed oracle10g on m/c(32bit).
but i don't know in which vc++ version it is built.
I have created the appl. in vs2005 (vc++ 8). and it is giving problem.

but the strange thing is when i use that in vc++ 6.0, it works fine.
I guess it is bcoz occi dlls are built in vc++6.0.

And i think you are right. I am using it in vs2005(vc++8) that's why it is giving problem.

Plz give me some solution.
Thanks in Advance!!!

I am facing same issue, did you get the resolution by any chance?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.