Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to join a featureclass contained inside a pgdb with a table created with an InMemory Workspace.

The in-memory table contains results that I want to use to define symbology on the featureclass.

The creation of the table goes well, I'm able to see the calculated data, but the IRelationshipClass created returns no records. I tried to use multiple fields to join the data without success. I also added the created table to ArcMap to create the join directcly in ArcMap, without success. It passes all the validations, but returns no records.

I tried to join my inmemory table with a shapefile featureclass instead and it worked.

Here's a sample of code

            // Create an in-memory workspace factory.
            IWorkspaceFactoryPtr ipWorkspaceFactory(CLSID_InMemoryWorkspaceFactory);

            // Create a new in-memory workspace. This returns a name object.
            IWorkspaceNamePtr ipWorkspaceName;
            ipWorkspaceFactory->Create(NULL, L"ValeursCalculees", NULL, 0, &ipWorkspaceName);

            INamePtr ipName(ipWorkspaceName);

            // Open the workspace through the name object.
            IUnknownPtr ipWorkspaceUnk;
            ipName->Open(&ipWorkspaceUnk);
            IWorkspacePtr ipWorkspace(ipWorkspaceUnk);

            IFeatureWorkspacePtr ipMemoryFeatureWorkspace(ipWorkspace);

            IDatasetPtr ipFeatureClassDataset(ipFeatureClass);
            CComBSTR strNomFC;
            ipFeatureClassDataset->get_Name(&strNomFC);

            IFieldsEditPtr ipFieldsEdit(CLSID_Fields);

                      ... Field creation code ...

            ITablePtr ipTable;
            ipMemoryFeatureWorkspace->CreateTable("InMemoryTable", ipFieldsEdit, NULL, NULL, NULL, &ipTable);

                     ... Table Filling code ...

            //IRelQueryTable
            IFeatureWorkspacePtr ipFeatureWorkspace(CTools::GetWorkspaceFromFeatureClass(ipFeatureClass));
            IObjectClassPtr ipObjectClass(ipTable);

            IMemoryRelationshipClassFactoryPtr ipMemoryRelationshipClassFactory(CLSID_MemoryRelationshipClassFactory);
            IRelationshipClassPtr ipRelClass;
            HRESULT hr = ipMemoryRelationshipClassFactory->Open(L"Join", ipFeatureClass, L"Numero_AD", ipObjectClass, L"NumeroAD", L"forward", L"backward", esriRelCardinalityOneToMany, &ipRelClass);

            IDisplayRelationshipClassPtr ipDisplayRelationshipClass(ipFeatureLayer);
            ipDisplayRelationshipClass->DisplayRelationshipClass(ipRelClass, esriLeftOuterJoin);

            //Add the table to ArcMap
            IStandaloneTableCollectionPtr ipStandaloneTableCollection(CTools::GetMap(ipMxDocument));
            IStandaloneTablePtr ipStandaloneTable(CLSID_StandaloneTable);
            ipStandaloneTable->putref_Table(ipTable);
            hr = ipStandaloneTableCollection->AddStandaloneTable(ipStandaloneTable);
            ipMxDocument->UpdateContents();

Am-I trying to do something impossible?

share|improve this question
1  
This is just an idea and would require you to change how you develop you code. If an In_Memory table is important to you maybe you can use the GeoProcessor and call the geo-processing tools CreateTable (setting output location to be In_Memory) and ultimately the Join tool? Rather than program in ArcObjects call the GeoProcessor tools... –  Hornbydd Dec 20 '12 at 18:24
    
When you create an In_Memory with the geo-processing tools, it actually creates a FileGDBScratchWorkspace ( A temporary file geodatabase in the user's temp directory) –  Goldorak84 Dec 20 '12 at 19:44
    
It says on this page that in_memory is RAM: resources.arcgis.com/en/help/main/10.1/index.html#//… –  Hornbydd Dec 20 '12 at 20:51
    
I read that article while searching for solutions. When I tried to create an in memory table in ArcMap 10.1 with the ArcToolbox "Create Table" tool, it created the table in a scratch file GDB, located in my temp folder. Maybe I'm not using the same tool that you mentioned. –  Goldorak84 Dec 21 '12 at 13:38

2 Answers 2

up vote 1 down vote accepted

After experimentation, no, it's not possible to create a valid join between a feature class and a table created with an InMemoryWorkspaceFactory. The join is created but it returns no records. It seems to be a limitation in the interaction between InMemoryWorkspace and Geodatabase workspace.

I found a workaround by replacing the InMemoryWorkspaceFactory with a FileGDBScratchWorkspaceFactory. It's a temporary FileGDB workspace stored in the user's temp folder.

The code looks like this

// Create a scratch (temporary) workspace factory.
IScratchWorkspaceFactory2Ptr ipWorkspaceFactory(CLSID_FileGDBScratchWorkspaceFactory);

// Create a new scratch (temporary) workspace. This returns a name object.
IWorkspaceNamePtr ipWorkspaceName;
IWorkspacePtr ipWorkspace;
ipWorkspaceFactory->CreateNewScratchWorkspace(&ipWorkspace);
share|improve this answer

yes IT IS POSSIBLE.

I work with Java, but I had the same probleme.

Solution: add UID to a table :

"UID uid1 = new UID(); uid1.setValue("esriGeoDatabase.Object"); tbl = featureWorkspace.createTable("myTable", fields, uid1, null, null);"

share|improve this answer
    
Thanks! I'll test it as soon as I can! –  Goldorak84 Jul 8 '13 at 16:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.