IWorkspace.ExecuteSQL does not work?

10-26-2011 02:11 AM
Esri Contributor

I tried to update a layer as below:
                    IWorkspaceProperties pp = mVersionedFeatureWorkspace as IWorkspaceProperties;
                    IWorkspaceProperty ap = pp.get_Property(esriWorkspacePropertyGroupType.esriWorkspacePropertyGroup, (int)esriWorkspacePropertyType.esriWorkspacePropCanExecuteSQL);
                    bool abc = ap.IsSupported;

                    if (abc)
                        IWorkspace pw = mVersionedFeatureWorkspace as IWorkspace;
                        pw.ExecuteSQL("update rwline set MaterialType = 4 where gid= 987654321");

the sql statement can be run without error, but unfortunately it also changed nothing. no specific record has been updated.

Is there something wrong I have?

Thank you.
2 Replies
Esri Contributor
Just found the caused issue.

If i am working on the default version, this statement works well.
but if i am working on the child version(IVersion mVersion = pDefaultVersionedWorpspace.FindVersion(sVersionName);), this statement doesn't work.

Is it a bug?


Esri Regular Contributor

Hi Bing,

To work on a version with SQLExecute you'll first need to set the versioned view via a stored procedure in your DBMS, otherwise it will only see the base table. 

The following topics explain how to access geodatabase data with SQL and versioned views (previously called multiversioned views)

SQL access to enterprise geodatabase data—ArcMap | Documentation 

What is a versioned view?—ArcMap | Documentation 

0 Kudos