Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

No values for varchar in cx_Oracle

limorAug 2 2016 — edited Aug 3 2016

Hi,

I have a column inside my orace database with type varchar2(256Byte).

And now I wrote a webserver with web.py and cx_Oracle to do a query and fetch the result.

The problem is I get no values for this column. But curiously it works for another column with the same type.

code:

import cx_Oracle

import json

import web

urls = (

    "/", "index",

    "/grid", "grid",

)

app = web.application(urls, globals())

web.config.debug = True

connection = cx_Oracle.Connection("TEST_3D/limo1013@10.40.33.160:1521/sdetest")

typeObj = connection.gettype("MDSYS.SDO_GEOMETRY")

class index:

    def GET(self):

        return "hallo moritz "

class grid:

    def GET(self):

        web.header('Access-Control-Allow-Origin', '*')

        web.header('Access-Control-Allow-Credentials', 'true')

        web.header('Content-Type', 'application/json')

        cursor = connection.cursor()

        cursor.arraysize = 100000  # default = 50

        cursor.execute(

            """SELECT a.id , a.json2, d.Classname FROM   building a, THEMATIC_SURFACE b, SURFACE_GEOMETRY c, OBJECTCLASS d  WHERE  a.grid_id_500 = 2728 AND a.id = b.BUILDING_ID AND b.LOD2_MULTI_SURFACE_ID = c.ROOT_ID AND c.GEOMETRY IS NOT NULL           AND b.OBJECTCLASS_ID = d.ID""")

       obj = cursor.fetchone()

       print obj

        result = []

        for id, json2, classname in cursor:

            result.append({

                "building_nr":id,"geometry": {

                  "type":"polygon","coordinates":json2,}, "polygon_typ":classname,})

  return result

if __name__ == "__main__":

    app.run(web.profiler)

For json2 I get no values:

[{'building_nr': 1314867, 'geometry': {'type': 'polygon', 'coordinates': None}, 'polygon_typ': 'BuildingWallSurface'},....

What is wrong?

Comments

Gaz in Oz

Hi limor,

what does the query return if you run it in sqlplus or sqldeveloper?

Does the column "a.json2" hold a value?

Cheers,

Gaz.

limor

Hey Gaz,

if I run the query :  SELECT a.id , a.json2, d.Classname FROM   building a, THEMATIC_SURFACE b, SURFACE_GEOMETRY c, OBJECTCLASS d  WHERE  a.grid_id_500 = 2728 AND a.id = b.BUILDING_ID AND b.LOD2_MULTI_SURFACE_ID = c.ROOT_ID AND c.GEOMETRY IS NOT NULL AND b.OBJECTCLASS_ID = d.ID

I get this result in sqldeveloper: type=VARCHAR:

IDJSON2CLASSNAME
1314867{"type":"Polygon","coordinates":[[[3481982,51,5384100,92,622,59],[3481984,51,5384091,11,626,54],[3482009,33,5384095,9,626,46],[3482007,21,5384106,12,622,34],[3481982,51,5384100,92,622,59]]]}BuildingWallSurface
1314867{"type":"Polygon","coordinates":[[[3481982,51,5384100,92,622,59],[3481984,51,5384091,11,626,54],[3482009,33,5384095,9,626,46],[3482007,21,5384106,12,622,34],[3481982,51,5384100,92,622,59]]]}BuildingWallSurface

But in cx_Oracle I get NONE vaules!!!

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 31 2016
Added on Aug 2 2016
2 comments
761 views