Re: [cx-oracle-users] type object matching - BINARY
Brought to you by:
atuining
From: D.R. B. <da...@as...> - 2006-09-13 15:24:29
|
Hello Mario, The pep that you refer to, http://www.python.org/dev/peps/pep-0249/ contains the answer to your question, although I'll admit that it's not obvious. In the pep you'll find a helper class DBAPITypeObject without an explanation on how to use it. A simple example hopefully explains what you'll have to do >>> import cx_Oracle >>> print DBAPITypeObject(cx_Oracle.CLOB) == DBAPITypeObject(cx_Oracle.BINARY, cx_Oracle.BLOB, cx_Oracle.CLOB) True >>> print DBAPITypeObject(cx_Oracle.NUMBER) == DBAPITypeObject(cx_Oracle.BINARY, cx_Oracle.BLOB, cx_Oracle.CLOB) False So, on the left side of the comparison you instantiate a DBAPITypeObject with the type identifier that you obtained from the cursor description. On the right side you instantiate a DBAPITypeObject with _all_ the type identifiers that you think behave the same as one of the type identifiers mentioned in the pep. In the above example, cx_Oracle.BINARY cx_Oracle.BLOB and cx_Oracle.CLOB are all considered BINARY. The DBAPITypeObject will make sure that the equivalence operator will behave as you expect. Of course, to make the code independent of the database backend you'll have to do a bit more, but this should explain how to do it. Good luck, Danny On Wed, Sep 13, 2006 at 05:07:41PM +0200, Mario Frasca wrote: > On 2006-0913 08:09:50, Anthony Tuininga wrote: > > To answer your question: Oracle has three types that hold binary > > data -- RAW, LONG RAW and BLOB. They are all quite different > > [...] Please feel free to educate me if necessary. :-) > > I'm a very bad educator! :) I hope I will manage to explain myself > at least. > > let's start from the problem I'm trying to solve... I need to perform a > SELECT DISTINCT <fields> FROM ... and I don't want to make any > assumptions about the table... I know that the table may contain LOBs > and on them Oracle complains that it cannot perform a comparison. to be > safe, I want to filter out all ''BINARY'' fields, in the sense, all > those fields where comparison is not possible or would take too long a > time... as stated in the PEP249: > > BINARY > This type object is used to describe (long) binary columns > in a database (e.g. LONG, RAW, BLOBs). > > this 'BINARY' is not a type, but a type object, something quite abstract > that is used to cathegorize the concrete types in the database into > db-api2 concepts. back to my question, at the very least > cx_Oracle.BINARY == cx_Oracle.BLOB > should check True... my interpretation is that also LOBs and CLOBs are > cathegorized as BINARY... but this is my interpretation... > > thanks for your time, > Mario > > -- > ... hinc sequitur, unamquamque rem naturalem tantum iuris ex natura habere, > quantum potentiae habet ad existendum et operandum ... > -- Baruch de Spinoza, TRACTATUS POLITICUS > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |