sqldata/sqlpgapi.cpp
// Set version of the connected database
Set version of the connected database
Set version of the connected database
void SqlPgApi::SetVersion()
{
	const char *query = "SELECT version()";
	PGresult *res = _PQexec(_conn, query);
	char *value = NULL;
	if(_PQresultStatus(res) == PGRES_TUPLES_OK)
	{
		value = _PQgetvalue(res, 0, 0);
		_version.assign(value);
	}
	if(value != NULL && strlen(value) > 11)
	{
		sscanf(value + 11, "%d.%d.%d", &_version_major, &_version_minor, &_version_release); 
	}
	_PQclear(res);
}
void SqlPgApi :: SetVersion ( ) { const char * query = " " ; PGresult * res = _PQexec ( _conn , query ) ; char * value = NULL ; if ( _PQresultStatus ( res ) == PGRES_TUPLES_OK ) { value = _PQgetvalue ( res , 0 , 0 ) ; _version . assign ( value ) ; } if ( value != NULL && strlen ( value ) > 11 ) { sscanf ( value + 11 , " " , & _version_major , & _version_minor , & _version_release ) ; } _PQclear ( res ) ; }
Set version of the connected database
Set version of the connected database
// Values returned: // PostgreSQL 9.0.4, compiled by Visual C++ build 1500, 32-bit // PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 32-bit // Execute the statement // Get the value of the first column of the first row // Define major, minor and release numbers // Skip "PostgreSQL "