本文整理汇总了C++中CPLODBCStatement类的典型用法代码示例。如果您正苦于以下问题:C++ CPLODBCStatement类的具体用法?C++ CPLODBCStatement怎么用?C++ CPLODBCStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPLODBCStatement类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPLODBCStatement
OGRLayer * OGRWalkDataSource::ExecuteSQL( const char *pszSQLCommand,
OGRGeometry *poSpatialFilter,
const char *pszDialect )
{
/* -------------------------------------------------------------------- */
/* Use generic implementation for recognized dialects */
/* -------------------------------------------------------------------- */
if( IsGenericSQLDialect(pszDialect) )
return OGRDataSource::ExecuteSQL( pszSQLCommand,
poSpatialFilter,
pszDialect );
/* -------------------------------------------------------------------- */
/* Execute normal SQL statement in Walk. */
/* Table_name = Layer_name + Postfix */
/* Postfix: "Features", "Annotations" or "Styles" */
/* -------------------------------------------------------------------- */
CPLODBCStatement *poStmt = new CPLODBCStatement( &oSession );
CPLDebug( "Walk", "ExecuteSQL(%s) called.", pszSQLCommand );
poStmt->Append( pszSQLCommand );
if( !poStmt->ExecuteSQL() )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s", oSession.GetLastError() );
delete poStmt;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Are there result columns for this statement? */
/* -------------------------------------------------------------------- */
if( poStmt->GetColCount() == 0 )
{
delete poStmt;
CPLErrorReset();
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create a results layer. It will take ownership of the */
/* statement. */
/* -------------------------------------------------------------------- */
OGRWalkSelectLayer *poLayer = NULL;
poLayer = new OGRWalkSelectLayer( this, poStmt );
if( poSpatialFilter != NULL )
poLayer->SetSpatialFilter( poSpatialFilter );
return poLayer;
}
示例2: CPLODBCStatement
OGRLayer * OGRODBCDataSource::ExecuteSQL( const char *pszSQLCommand,
OGRGeometry *poSpatialFilter,
const char *pszDialect )
{
/* -------------------------------------------------------------------- */
/* Use generic implementation for recognized dialects */
/* -------------------------------------------------------------------- */
if( IsGenericSQLDialect(pszDialect) )
return OGRDataSource::ExecuteSQL( pszSQLCommand,
poSpatialFilter,
pszDialect );
/* -------------------------------------------------------------------- */
/* Execute statement. */
/* -------------------------------------------------------------------- */
CPLODBCStatement *poStmt = new CPLODBCStatement( &oSession );
CPLDebug( "ODBC", "ExecuteSQL(%s) called.", pszSQLCommand );
poStmt->Append( pszSQLCommand );
if( !poStmt->ExecuteSQL() )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s", oSession.GetLastError() );
delete poStmt;
return nullptr;
}
/* -------------------------------------------------------------------- */
/* Are there result columns for this statement? */
/* -------------------------------------------------------------------- */
if( poStmt->GetColCount() == 0 )
{
delete poStmt;
CPLErrorReset();
return nullptr;
}
/* -------------------------------------------------------------------- */
/* Create a results layer. It will take ownership of the */
/* statement. */
/* -------------------------------------------------------------------- */
OGRODBCSelectLayer* poLayer = new OGRODBCSelectLayer( this, poStmt );
if( poSpatialFilter != nullptr )
poLayer->SetSpatialFilter( poSpatialFilter );
return poLayer;
}
示例3: CPLODBCStatement
OGRLayer * OGRGeomediaDataSource::ExecuteSQL( const char *pszSQLCommand,
OGRGeometry *poSpatialFilter,
const char *pszDialect )
{
/* -------------------------------------------------------------------- */
/* Use generic imlplementation for OGRSQL dialect. */
/* -------------------------------------------------------------------- */
if( pszDialect != NULL && EQUAL(pszDialect,"OGRSQL") )
return OGRDataSource::ExecuteSQL( pszSQLCommand,
poSpatialFilter,
pszDialect );
/* -------------------------------------------------------------------- */
/* Execute statement. */
/* -------------------------------------------------------------------- */
CPLODBCStatement *poStmt = new CPLODBCStatement( &oSession );
poStmt->Append( pszSQLCommand );
if( !poStmt->ExecuteSQL() )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s", oSession.GetLastError() );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Are there result columns for this statement? */
/* -------------------------------------------------------------------- */
if( poStmt->GetColCount() == 0 )
{
delete poStmt;
CPLErrorReset();
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create a results layer. It will take ownership of the */
/* statement. */
/* -------------------------------------------------------------------- */
OGRGeomediaSelectLayer *poLayer = NULL;
poLayer = new OGRGeomediaSelectLayer( this, poStmt );
if( poSpatialFilter != NULL )
poLayer->SetSpatialFilter( poSpatialFilter );
return poLayer;
}
示例4: GetLayerDefn
int OGRMSSQLSpatialTableLayer::GetFeatureCount( int bForce )
{
GetLayerDefn();
if( TestCapability(OLCFastFeatureCount) == FALSE )
return OGRMSSQLSpatialLayer::GetFeatureCount( bForce );
ClearStatement();
CPLODBCStatement* poStatement = BuildStatement( "count(*)" );
if (poStatement == NULL || !poStatement->Fetch())
{
delete poStatement;
return OGRMSSQLSpatialLayer::GetFeatureCount( bForce );
}
int nRet = atoi(poStatement->GetColData( 0 ));
delete poStatement;
return nRet;
}
示例5: CPLODBCStatement
int OGRMSSQLSpatialTableLayer::FetchSRSId()
{
CPLODBCStatement oStatement = CPLODBCStatement( poDS->GetSession() );
oStatement.Appendf( "select srid from geometry_columns "
"where f_table_schema = '%s' and f_table_name = '%s'",
pszSchemaName, pszTableName );
if( oStatement.ExecuteSQL() && oStatement.Fetch() )
{
if ( oStatement.GetColData( 0 ) )
nSRSId = atoi( oStatement.GetColData( 0 ) );
}
return nSRSId;
}
示例6: while
OGRLayer * OGRMSSQLSpatialDataSource::ExecuteSQL( const char *pszSQLCommand,
OGRGeometry *poSpatialFilter,
const char *pszDialect )
{
/* -------------------------------------------------------------------- */
/* Use generic imlplementation for OGRSQL dialect. */
/* -------------------------------------------------------------------- */
if( pszDialect != NULL && EQUAL(pszDialect,"OGRSQL") )
return OGRDataSource::ExecuteSQL( pszSQLCommand,
poSpatialFilter,
pszDialect );
/* -------------------------------------------------------------------- */
/* Special case DELLAYER: command. */
/* -------------------------------------------------------------------- */
if( EQUALN(pszSQLCommand,"DELLAYER:",9) )
{
const char *pszLayerName = pszSQLCommand + 9;
while( *pszLayerName == ' ' )
pszLayerName++;
for( int iLayer = 0; iLayer < nLayers; iLayer++ )
{
if( EQUAL(papoLayers[iLayer]->GetName(),
pszLayerName ))
{
DeleteLayer( iLayer );
break;
}
}
return NULL;
}
CPLDebug( "MSSQLSpatial", "ExecuteSQL(%s) called.", pszSQLCommand );
if( EQUALN(pszSQLCommand, "DROP SPATIAL INDEX ON ", 22) )
{
/* Handle command to drop a spatial index. */
OGRMSSQLSpatialTableLayer *poLayer = new OGRMSSQLSpatialTableLayer( this );
if (poLayer)
{
if( poLayer->Initialize( "dbo", pszSQLCommand + 22, NULL, 0, 0, wkbUnknown ) != CE_None )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to initialize layer '%s'", pszSQLCommand + 22 );
}
poLayer->DropSpatialIndex();
delete poLayer;
}
return NULL;
}
else if( EQUALN(pszSQLCommand, "CREATE SPATIAL INDEX ON ", 24) )
{
/* Handle command to create a spatial index. */
OGRMSSQLSpatialTableLayer *poLayer = new OGRMSSQLSpatialTableLayer( this );
if (poLayer)
{
if( poLayer->Initialize( "dbo", pszSQLCommand + 24, NULL, 0, 0, wkbUnknown ) != CE_None )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to initialize layer '%s'", pszSQLCommand + 24 );
}
poLayer->CreateSpatialIndex();
delete poLayer;
}
return NULL;
}
/* Execute the command natively */
CPLODBCStatement *poStmt = new CPLODBCStatement( &oSession );
poStmt->Append( pszSQLCommand );
if( !poStmt->ExecuteSQL() )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s", oSession.GetLastError() );
delete poStmt;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Are there result columns for this statement? */
/* -------------------------------------------------------------------- */
if( poStmt->GetColCount() == 0 )
{
delete poStmt;
CPLErrorReset();
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create a results layer. It will take ownership of the */
/* statement. */
/* -------------------------------------------------------------------- */
OGRMSSQLSpatialSelectLayer *poLayer = NULL;
//.........这里部分代码省略.........