Skip to content

Commit

Permalink
oracle provider: add updates on lob fields
Browse files Browse the repository at this point in the history
(cherry picked from commit b61d932)
  • Loading branch information
jef-n committed Sep 3, 2016
1 parent 474b9d8 commit 0036274
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1741,7 +1741,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 @@ -1762,10 +1762,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 @@ -1784,15 +1789,24 @@ 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() );
}

appendGeomParam( g, qry );
QgsGeometry g;
if ( !attrs[idx].isNull() )
{
g = QgsGeometry::fromWkt( attrs[ idx ].toString() );
}
appendGeomParam( g, qry );
}
else if ( fld.typeName().endsWith( "LOB" ) )
{
qry.addBindValue( attrs[ idx ] );
}
}

if ( !qry.exec() )
Expand Down

0 comments on commit 0036274

Please sign in to comment.