sqldata/sqlifmxapi.cpp
// Read references between foreign key and primary key constraints 
Read references between foreign key and primary key constraints
Read references between foreign key and primary key constraints
int SqlIfmxApi::ReadReferences(std::string & )
{
	std::string query = "SELECT constrid, primary FROM sysreferences";
	size_t col_count = 0;
	size_t allocated_rows = 0;
	int rows_fetched = 0; 
	size_t time_read = 0;
	SqlCol *cols = NULL;
	int rc = OpenCursor(query.c_str(), 100, 0, &col_count, &allocated_rows, &rows_fetched, &cols, 
		&time_read, true);
	while(rc >= 0)
	{
		for(int i = 0; i < rows_fetched; i++)
		{
			int cnsid = 0;
			int r_cnsid = 0;
			SQLLEN len = (SQLLEN)cols[0].ind[i];
			if(len == 4)
				cnsid = *((int*)(cols[0]._data + cols[0]._fetch_len * i));
			len = (SQLLEN)cols[1].ind[i];
			if(len == 4)
				r_cnsid = *((int*)(cols[1]._data + cols[1]._fetch_len * i));
			for(std::list<SqlConstraints>::iterator m = _table_constraints.begin(); m != _table_constraints.end(); m++)
			{
				if((*m).cnsid == cnsid)
				{
					(*m).r_cnsid = r_cnsid;
					break;
				}
			}
		}
		rc = Fetch(&rows_fetched, &time_read);
		if(rc == 100)
			break;
	}
	CloseCursor();
	return 0;
}
int SqlIfmxApi :: ReadReferences ( std :: string & ) { std :: string query = " " ; size_t col_count = 0 ; size_t allocated_rows = 0 ; int rows_fetched = 0 ; size_t time_read = 0 ; SqlCol * cols = NULL ; int rc = OpenCursor ( query . c_str ( ) , 100 , 0 , & col_count , & allocated_rows , & rows_fetched , & cols , & time_read , true ) ; while ( rc >= 0 ) { for ( int i = 0 ; i < rows_fetched ; i ++ ) { int cnsid = 0 ; int r_cnsid = 0 ; SQLLEN len = ( SQLLEN ) cols [ 0 ] . ind [ i ] ; if ( len == 4 ) cnsid = * ( ( int * ) ( cols [ 0 ] . _data + cols [ 0 ] . _fetch_len * i ) ) ; len = ( SQLLEN ) cols [ 1 ] . ind [ i ] ; if ( len == 4 ) r_cnsid = * ( ( int * ) ( cols [ 1 ] . _data + cols [ 1 ] . _fetch_len * i ) ) ; for ( std :: list < SqlConstraints > :: iterator m = _table_constraints . begin ( ) ; m != _table_constraints . end ( ) ; m ++ ) { if ( ( * m ) . cnsid == cnsid ) { ( * m ) . r_cnsid = r_cnsid ; break ; } } } rc = Fetch ( & rows_fetched , & time_read ) ; if ( rc == 100 ) break ; } CloseCursor ( ) ; return 0 ; }
Read references between foreign key and primary key constraints
Read references between foreign key and primary key constraints
/*condition*/ // Open cursor allocating 100 rows buffer // Copy column information // Foreign key constraint ID (INTEGER) // Primary key constraint ID (INTEGER) // Find foreign key constraint and set primary key // No more rows