Print Thread
Page 1 of 3 1 2 3
How to update SDO_GEOMETRY column
#5952 02/02/04 09:46 PM
Joined: Feb 2004
Posts: 7
M
Member
OP Offline
Member
M
Joined: Feb 2004
Posts: 7
We're trying to update a table, that contains a column 'SHAPE' of type 'SDO_GEOMETRY', but that far with no success.

Could you please point me to an example of how to update an object column? All examples I found refer to typed tables and not a single object column.

Re: How to update SDO_GEOMETRY column
#5953 02/02/04 10:28 PM
Joined: Aug 1999
Posts: 22,210
Member
Offline
Member
Joined: Aug 1999
Posts: 22,210
What is your Direct Oracle Access version?


Marco Kalter
Allround Automations
Re: How to update SDO_GEOMETRY column
#5954 02/03/04 03:07 PM
Joined: Feb 2004
Posts: 7
M
Member
OP Offline
Member
M
Joined: Feb 2004
Posts: 7
Delphi 7, DOA 4.0.3 trial version with Oracle 9.2

Just wanted to know if there is an example in your documentation. (Not using typed tables...)
If not, I would be pleased if you could post a few lines to show me how do do it.

Re: How to update SDO_GEOMETRY column
#5955 02/03/04 10:47 PM
Joined: Aug 1999
Posts: 22,210
Member
Offline
Member
Joined: Aug 1999
Posts: 22,210
I checked out the SDO_GEOMETRY type and noticed that it contains a VARRAY, which cannot be updated through the TOracleDataSet. Therefore you would need a TOracleQuery and TOracleObject to update this record. I don't have an example that uses the SDO_GEOMERTY type, but the documentation contains various examples for nested objects an collections.


Marco Kalter
Allround Automations
Re: How to update SDO_GEOMETRY column
#5956 02/03/04 11:16 PM
Joined: Feb 2004
Posts: 7
M
Member
OP Offline
Member
M
Joined: Feb 2004
Posts: 7
I found some examples, but as I said they all refer to typed tables.
If I look at TOracleObject.Create I have to give a tablename as third parameter to make the object persistent. But I don't have a table, I only have a _column_.

Let's say I have a table with three columns:
ID number
SomeText varchar2(100)
SHAPE SDO_GEOMETRY

How can I create an updatable TOracleObject instance for the value in the "SHAPE" column?

Re: How to update SDO_GEOMETRY column
#5957 02/04/04 02:39 AM
Joined: Nov 2003
Posts: 89
Germany
A
al0 Offline
Member
Offline
Member
A
Joined: Nov 2003
Posts: 89
Germany
[quote]Originally posted by Marco Kalter:
I checked out the SDO_GEOMETRY type and noticed that it contains a VARRAY, which cannot be updated through the TOracleDataSet. [/quote]Are there any plans to make collection type columns updatable through dataset (or nested dataset) in future releases of DOA?

Re: How to update SDO_GEOMETRY column
#5958 02/04/04 10:48 PM
Joined: Aug 1999
Posts: 22,210
Member
Offline
Member
Joined: Aug 1999
Posts: 22,210
Nested tables are updateable. Varrays are currently read-only. This will be addressed in a future release.


Marco Kalter
Allround Automations
Re: How to update SDO_GEOMETRY column
#5959 02/05/04 08:41 PM
Joined: Feb 2004
Posts: 7
M
Member
OP Offline
Member
M
Joined: Feb 2004
Posts: 7
Please, back to the topic.
I never said I wanted to update through a TOracleDataset. Using TOracleQuery with variables or a TOracleObject instance would be fine.

Meanwhile I learned the following:
"REF cannot operate on column objects or otherwise nested objects, because such objects do not have an OID." [PL/SQL Programming, Steven Feuerstein]

So, object columns do not have a reference pointer. Thus, they are not so called "persistant objects"
Could that be the problem, that I can't write into a TOracleObject instance?

How about an example on using TOracleQuery and variables to update an object column? Still couldn't find one in your documentation.

Re: How to update SDO_GEOMETRY column
#5960 02/06/04 09:01 PM
Joined: Aug 1999
Posts: 22,210
Member
Offline
Member
Joined: Aug 1999
Posts: 22,210
The object is indeed not persistent, so you will have to query or create a TOracleObject of a SDO_GEOMETRY type, manipulate its attributes, and execute an update or insert that uses an object variable that is associated with this TOracleObject instance.

I will create a complete SDO_GEOMETRY example and post it here shortly.


Marco Kalter
Allround Automations
Re: How to update SDO_GEOMETRY column
#5961 02/09/04 10:45 PM
Joined: Aug 1999
Posts: 22,210
Member
Offline
Member
Joined: Aug 1999
Posts: 22,210
The procedure below is an example how to insert, select and update an sdo_geometry column in a table.
The demo uses a transient object instead of pure SQL to access the attributes and collections.
All components are created at runtime instead of designtime for demo purposes.
Code
procedure SDOGeometryDemo;
var Session: TOracleSession;
    Query: TOracleQuery;
    Polygon, ElemInfo, Ordinates: TOracleObject;
begin
  // Create a session and logon as scott
  Session := TOracleSession.Create(nil);
  Session.LogonUsername := 'scott';
  Session.LogonPassword := 'tiger';
  Session.LogOn;
  // Create a query to create/access/drop table
  Query := TOracleQuery.Create(nil);
  Query.Session := Session;
  with Query do
  begin
    // Create the table
    SQL.Text := 'create table cola_markets(mkt_id number, name varchar2(32), shape mdsys.sdo_geometry)';
    Execute;
    // Create a transient SDO_GEOMETRY object instance
    Polygon := TOracleObject.Create(Session, 'mdsys.sdo_geometry', '');
    // Set the type to a 2 dimensional polygon
    Polygon.SetAttr('sdo_gtype', 2001);
    // Define a rectangle
    ElemInfo := Polygon.ObjAttr('sdo_elem_info');
    ElemInfo.Elements[0] := 1;
    ElemInfo.Elements[1] := 1003;
    ElemInfo.Elements[2] := 3;
    // Set 2 points at 1,1 and 5,7
    Ordinates := Polygon.ObjAttr('sdo_ordinates');
    Ordinates.Elements[0] := 1;
    Ordinates.Elements[1] := 1;
    Ordinates.Elements[2] := 5;
    Ordinates.Elements[3] := 7;
    // Insert a record with this object instance
    SQL.Text := 'insert into cola_markets(mkt_id, name, shape) values (1, ''cola_a'', :polygon)';
    DeclareVariable('polygon', otObject);
    SetComplexVariable('polygon', Polygon);
    Execute;
    Session.Commit;
    // Free the object
    Polygon.Free;
    // Requery the row with the previously inserted object instance
    Clear;
    SQL.Text := 'select * from cola_markets where mkt_id = 1';
    Execute;
    if not Eof then
    begin
      // Create a copy of the queried instance
      Polygon := TOracleObject.Create(Session, 'mdsys.sdo_geometry', '');
      Polygon.Assign(ObjField('shape'));
      // Change the 2nd point from 5,7 to 6,8
      Polygon.ObjAttr('sdo_ordinates').Elements[2] := 6;
      Polygon.ObjAttr('sdo_ordinates').Elements[3] := 8;
      // Update the record with this modified object instance
      Clear;
      SQL.Text := 'update cola_markets set shape = :polygon where mkt_id = 1';
      DeclareVariable('polygon', otObject);
      SetComplexVariable('polygon', Polygon);
      Execute;
      Session.Commit;
      // Free the object
      Polygon.Free;
    end;
    // Drop the table
    Clear;
    SQL.Text := 'drop table cola_markets';
    Execute;
  end;
  // Free the query and session
  Query.Free;
  Session.Free;
end;


Marco Kalter
Allround Automations
Page 1 of 3 1 2 3

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.053s Queries: 15 (0.006s) Memory: 2.5656 MB (Peak: 3.0378 MB) Data Comp: Off Server Time: 2024-05-06 09:59:09 UTC
Valid HTML 5 and Valid CSS