Skip to content

Commit

Permalink
oracle provider: add updates on lob fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Sep 3, 2016
1 parent 8688fef commit b61d932
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1743,7 +1743,7 @@ bool QgsOracleProvider::changeAttributeValues( const QgsChangedAttributesMap &at
QString sql = QString( "UPDATE %1 SET " ).arg( mQuery );

bool pkChanged = false;
QList<int> geometryParams;
QList<int> params;

// cycle through the changed attributes of the feature
QString delim;
Expand All @@ -1764,10 +1764,15 @@ bool QgsOracleProvider::changeAttributeValues( const QgsChangedAttributesMap &at
sql += QString( "SDO_UTIL.FROM_WKTGEOMETRY(%1)" ).arg( quotedValue( siter->toString() ) );
else
{
geometryParams << siter.key();
params << siter.key();
sql += "?";
}
}
else if ( fld.typeName().endsWith( "LOB" ) )
{
params << siter.key();
sql += "?";
}
else
{
sql += quotedValue( *siter, fld.type() );
Expand All @@ -1786,21 +1791,30 @@ bool QgsOracleProvider::changeAttributeValues( const QgsChangedAttributesMap &at
throw OracleException( tr( "Could not prepare update statement." ), qry );
}

Q_FOREACH ( int idx, geometryParams )
Q_FOREACH ( int idx, params )
{
QgsGeometry *g;
if ( !attrs[idx].isNull() )
const QgsField &fld = field( idx );

if ( fld.typeName().endsWith( ".SDO_GEOMETRY" ) )
{
g = QgsGeometry::fromWkt( attrs[ idx ].toString() );
QgsGeometry *g;
if ( !attrs[idx].isNull() )
{
g = QgsGeometry::fromWkt( attrs[ idx ].toString() );
}
else
{
g = new QgsGeometry();
}

appendGeomParam( g, qry );

delete g;
}
else
else if ( fld.typeName().endsWith( "LOB" ) )
{
g = new QgsGeometry();
qry.addBindValue( attrs[ idx ] );
}

appendGeomParam( g, qry );

delete g;
}

if ( !qry.exec() )
Expand Down

0 comments on commit b61d932

Please sign in to comment.