YouTube | Facebook | Twitter | RSS

Oracle スタンドアロン テーブルを直接更新する方法

2016/9/1 (木)

'使用ライセンスはEditor以上、Geodataabse Updateを使用すること
'ESRI Support #631518
     Dim pPropset As ESRI.ArcGIS.esriSystem.IPropertySet
     pPropset = New ESRI.ArcGIS.esriSystem.PropertySet
     '++ Create a new workspacefactory/workspace
     Dim pWorkspaceFact As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory
     pWorkspaceFact = New ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory
     With pPropset
         .SetProperty("SERVER", "hawkeye")
         .SetProperty("INSTANCE", "6161")
         .SetProperty("USER", "sde")
         .SetProperty("PASSWORD", "sdesde")
         .SetProperty("VERSION", "SDE.DEFAULT")
     End With
     Dim pWorkspace As ESRI.ArcGIS.Geodatabase.IWorkspace
     pWorkspace = pWorkspaceFact.Open(pPropset, 0)
     Dim SQLstr As String
     SQLstr = "create view SDE.TableVIEW_1A as select * from SDE.us_counties wheE_NAME = 'Washington'"
     Dim pFeatWorkspace As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace
     pFeatWorkspace = pWorkspace
     '++ Get the datasets (names) in the workspace
     Dim pEnumDataset As ESRI.ArcGIS.Geodatabase.IEnumDatasetName
     pEnumDataset = pWorkspace.DatasetNames(ESRI.ArcGIS.Geodatabase.esriDatasetTiDTTable)
     '++ Create a new dataset object for the table you want to load
     Dim pDataset As ESRI.ArcGIS.Geodatabase.IDatasetName
     pDataset = pEnumDataset.Next
     Dim tableViewName As String
     Do Until pDataset Is Nothing
         If pDataset.Name = "SDE.TableVIEW_1A" Then
             tableViewName = pDataset.Name
             Exit Do
         End If
         pDataset = pEnumDataset.Next
     '++ Create and open the new table object from the dataset name
     Dim pTable As ESRI.ArcGIS.Geodatabase.ITable
     pTable = pFeatWorkspace.OpenTable(pDataset.Name)
     '++ Create a table collection and assign the new table to it
     Dim pStTab As ESRI.ArcGIS.Carto.IStandaloneTable
     Dim pStTabColl As ESRI.ArcGIS.Carto.IStandaloneTableCollection
     Dim pMap As ESRI.ArcGIS.Carto.IMap
     Dim mx As ESRI.ArcGIS.ArcMapUI.IMxDocument
     mx = m_app.Document
     pMap = mx.FocusMap
     pStTab = New ESRI.ArcGIS.Carto.StandaloneTable
     pStTab.Table = pTable
     pStTabColl = pMap
     '++ Update the document
     '++ Create and open a new table window for the table
     Dim ptabWin As ESRI.ArcGIS.ArcMapUI.ITableWindow
     ptabWin = New ESRI.ArcGIS.ArcMapUI.TableWindow
     ptabWin.Table = pTable
     ptabWin.ShowAliasNamesInColumnHeadings = True
     ptabWin.Application = m_app
 Catch ex As Exception
 End Try
Sub AddRow()
    Dim tableName As String
    Dim databasePath As String
    databasePath = "C:\test_data\test.mdb"
    tableName = "test"
    Dim pPropset As IPropertySet
    Dim pWF As IWorkspaceFactory
    Dim fWS As IFeatureWorkspace
    Dim pTable As ITable
    Dim pCursor As ICursor
    Dim pRow As IRow
    Set pPropset = New PropertySet
    pPropset.SetProperty "DATABASE", databasePath
    pPropset.SetProperty "DATAPROVIDER", "Access Data Source"
    Set pWF = New AccessWorkspaceFactory
    Set fWS = pWF.Open(pPropset, 0)
    Dim pTransActions As ITransactions
    Set pTransActions = fWS
    'Start the transaction
    'Open the Table
    Set pTable = fWS.OpenTable(tableName)
    'Create new row and populate with values
    Set pRow = pTable.CreateRow
    pRow.Value(4) = "Test_1"
    pRow.Value(5) = "Test_2"
    'Abort the transaction
    ''Use ITransactions::CommitTransaction to commit the changes
End Sub


  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS