środa, 2 marca 2011

Dictionary iteration - ValueError: too many values to unpack

If you get the following error trying to iterate on a dictionary:
 
ValueError: too many values to unpack
 
you have forgotten add iteritems() method:
 
for k,v in dict.iteritems():
    print k, v

wtorek, 1 marca 2011

How to select value of SDO_GEOMETRY Object

http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_objrelschema.htm#i1004087

States:

"Oracle Spatial defines the object type SDO_GEOMETRY as:

CREATE TYPE sdo_geometry AS OBJECT (
 SDO_GTYPE NUMBER,
 SDO_SRID NUMBER,
 SDO_POINT SDO_POINT_TYPE,
 SDO_ELEM_INFO SDO_ELEM_INFO_ARRAY,
 SDO_ORDINATES SDO_ORDINATE_ARRAY);
"

Let's assume we have a "TABLE" with SDO_GEOMETRY Type field named "GEOM".
If you want to get the values of certain SDO_GEOMETRY Type field and make query like this:

select geom.SDO_GTYPE from table;

You'll get ORA-00904 Error: "invalid identifier".

Try with table name alias:

select t.geom.SDO_GTYPE from table t;

GEOM.SDO_GTYPE   
----------------------
2003