[fdo-internals] Re: insert error control properties with KingOracle

Simon Pelicon simon at sl-king.com
Fri Dec 2 02:10:09 EST 2011


Hi!

Do you run  IApplySchema command before every insert?
I yes,why?
All FDO providers read Schema when opening connection.

Simon

On Thu, Dec 1, 2011 at 4:10 PM, mdelsinne <mdelsinne at gmail.com> wrote:

> Mon code:
>
> // Connexion
> IConnectionManager connManager =
> FeatureAccessManager.GetConnectionManager();
> IConnection conn = connManager.CreateConnection("OSGeo.KingOracle.3.6");
> IConnectionPropertyDictionary connProperties =
> conn.ConnectionInfo.ConnectionProperties;
> OSGeo.FDO.Connections.ConnectionState connState = conn.ConnectionState;
> connProperties.SetProperty("Username", "FDO");
> connProperties.SetProperty("Password", "FDO");
> connProperties.SetProperty("Service", "BASETEST");
> connProperties.SetProperty("OracleSchema", "FDO");
> connProperties.SetProperty("KingFdoClass", "MYFDOCLASS");
> connState = conn.Open();
>
> // Schema & Class
> FeatureSchema aFeatureSchema = new FeatureSchema("KingOra", "");
> FeatureClass aFeatureClass = new FeatureClass("CLASSTEST", "");
>
> string proj = "";
>
> // Add a key property
> DataPropertyDefinition keyProp = new DataPropertyDefinition("KEY", "");
> keyProp.DataType = DataType.DataType_String;
> keyProp.Length = 255;
> aFeatureClass.Properties.Add(keyProp);
>
> // Add a name property
> DataPropertyDefinition nameProp = new DataPropertyDefinition("NAME", "");
> nameProp.DataType = DataType.DataType_String;
> nameProp.Length = 255;
> aFeatureClass.Properties.Add(nameProp);
>
> // Add a url property
> DataPropertyDefinition urlProp = new DataPropertyDefinition("URL", "");
> urlProp.DataType = DataType.DataType_String;
> urlProp.Length = 255;
> aFeatureClass.Properties.Add(urlProp);
>
> // Add a geometry property
> GeometricPropertyDefinition geomProp = new
> GeometricPropertyDefinition("GEOM", "");
> geomProp.GeometryTypes = (int)GeometryType.GeometryType_MultiGeometry;
> aFeatureClass.Properties.Add(geomProp);
> aFeatureClass.GeometryProperty = geomProp;
>
> // implement the changes
> aFeatureSchema.Classes.Add(aFeatureClass);
> IApplySchema applySchema =
>
> (IApplySchema)conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_ApplySchema);
> applySchema.FeatureSchema = aFeatureSchema;
> applySchema.Execute();
> applySchema.Dispose();
>
> // Preparer insertion des données
> IInsert cmdInsert =
>
> (IInsert)conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert);
> cmdInsert.SetFeatureClassName("FDO~CLASSTEST~GEOM");
>
> FgfGeometryFactory factory = new FgfGeometryFactory();
> IDirectPosition position = factory.CreatePositionXYZ(2, 2, 0);
> IPoint point = factory.CreatePoint(position);
> cmdInsert.PropertyValues.Add(new PropertyValue("KEY", new
> StringValue("strKey")));
> cmdInsert.PropertyValues.Add(new PropertyValue("NAME", new
> StringValue("strName")));
> cmdInsert.PropertyValues.Add(new PropertyValue("URL", new
> StringValue("strUrl)));
> cmdInsert.PropertyValues.Add(new PropertyValue("GEOM", new
> GeometryValue(factory.GetFgf(point))));
>
> // Insert
> IReader reader = cmdInsert.Execute();
> if (reader.ReadNext())
> {
>
> }
> reader.Close();
>
> Result in Oracle:
>
> http://osgeo-org.1803224.n2.nabble.com/file/n7050862/ora1.jpg
>
> http://osgeo-org.1803224.n2.nabble.com/file/n7050862/ora2.jpg
>
> Thank's
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/insert-error-control-properties-with-KingOracle-tp7046704p7050862.html
> Sent from the FDO Internals mailing list archive at Nabble.com.
> _______________________________________________
> fdo-internals mailing list
> fdo-internals at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-internals
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fdo-internals/attachments/20111202/4030c9e0/attachment.html


More information about the fdo-internals mailing list