[fdo-users] Updating Table dynamically

prem pkbalakrishnan at tatapowersed.com
Wed Jun 26 03:56:04 PDT 2013


hi Jackie,
We tried similar way what u suggested. Getting exception "Cannot Apply
Schema".
Posted Code below.

FdoPtr<FdoIDescribeSchema> ptrobjDescribeSchema =
(FdoIDescribeSchema*)m_objFDOConnection->CreateCommand(FdoCommandType_DescribeSchema);

FdoPtr<FdoFeatureSchemaCollection> ptrobjSchemaCollection =
ptrobjDescribeSchema->Execute();

FdoPtr<FdoFeatureSchema> ptrobjSchema =
ptrobjSchemaCollection->FindItem(L"public");

FdoPtr<FdoClassCollection> ptrobjFeatureClassCollection =
ptrobjSchema->GetClasses();

FdoPtr<FdoClassDefinition> ptrobjFeatureClass =
ptrobjFeatureClassCollection->FindItem(ConvertCharPToWCharP("demonetwork"));

FdoPtr<FdoPropertyDefinitionCollection> ptrobjPropDefColl;

if(ptrobjFeatureClass==NULL)

return INVALID_DATABASE;

ptrobjPropDefColl = ptrobjFeatureClass->GetProperties();

FdoPtr<FdoDataPropertyDefinition> ptrobjAttributeDataProperty =
FdoDataPropertyDefinition::Create(ConvertCharPToWCharP("test"),L"Attribute
added t store data needed for shrotest path calculation");

ptrobjAttributeDataProperty->SetDataType(FdoDataType_Boolean);

//ptrobjAttributeDataProperty->SetLength(200);

//ptrobjAttributeDataProperty->SetDefaultValue(tempstring);

ptrobjAttributeDataProperty->SetReadOnly(false);

ptrobjAttributeDataProperty->SetNullable(false);

ptrobjAttributeDataProperty->SetIsAutoGenerated(false);

ptrobjPropDefColl->Add(ptrobjAttributeDataProperty);

if(ptrobjFeatureClass->GetElementState() == FdoSchemaElementState_Modified)

{

std::cout<<"CHANGED"<<std::endl;

}

FdoPtr<FdoIApplySchema> ptrobjApplySchema =
(FdoIApplySchema*)m_objFDOConnection->CreateCommand(FdoCommandType_ApplySchema);

FdoPtr<FdoISchemaCapabilities> schemcapabilities =
m_objFDOConnection->GetSchemaCapabilities();

bool tempstat =false;

tempstat = schemcapabilities->SupportsSchemaModification();

tempstat = schemcapabilities->SupportsSchemaOverrides();

ptrobjApplySchema->SetFeatureSchema(ptrobjSchema);

ptrobjApplySchema->Execute();

}

catch(FdoCommandException *objException)

{

FdoStringP exceptionMessage = objException->GetExceptionMessage();

return EXCEPTION;

}

catch(FdoSchemaException *objException)

{

FdoException *ex;

ex = objException;

while (ex != NULL)

{

FdoStringP exceptionMessage = objException->GetExceptionMessage();

std::cout<<ConvertWCharPToCharP(exceptionMessage)<<std::endl;

FdoException *ex2 = objException->GetCause();

ex=ex2;

}

Regards,
Prem




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Updating-Table-dynamically-tp5062236p5062290.html
Sent from the FDO Users mailing list archive at Nabble.com.


More information about the fdo-users mailing list