DCOracle2 - Can't get cursor.execute to return data when SQL query involves datetimes.

Steve Holden sholden at holdenweb.com
Tue Jun 4 16:41:44 EDT 2002


"Jim" <jtt at hnc.com> wrote in message
news:be0d725a.0206041139.1f8f6647 at posting.google.com...
> Hello,
>
> I am trying to write a simple program to retrieve 2 colums from a
> table.
> I am running on Solaris 2.8, Python 2.1.1, DCOracle2 and Oracle
> 8.1.7.3.
>
>
> The columns are:
>
> acct_number   ( one char long)
> transaction_datestamp (oracle datetimestamp)
>
> Here is my program:
>
> import DCOracle2
> trandt = '19970110121212'
>
> db = DCOracle2.connect("uid/pwd")
> c = db.cursor()
>
> dt = DCOracle2.Timestamp(int(tran_date[0:4]), int(tran_date[4:6]),
> int(tran_date[6:8]), int(tran_date[8:10]), int(tran_date[10:12]),
> int(tran_date[12:14]))
>
> results = c.execute,('select acct_nbr, trn_dt from testtable where
> ACCT_NBR = :1 and TRN_DT = :2',"1",dt)
>
> aaa = c.fetchone()
>
> print aaa
>
>
> The execute never return any thing from query when the date timestamp
> is part of the query.  If I only query on the acct_nbr it returns the
> expected row.
>
> What am I missing ???
>

Possibly the cxOracle module from www.computronix.com :-)

Otherwise, please go away and *copy and paste* the real code: I'll overlook
the line wrapping, which your mailer probably inserted gratuitously, but you
appear to be using tran_date where you should be using trandt, and trn_dt
where you should be using transacttion_datestamp.

Finally, doesn't the .execute() method call want two arguments [i.e.,
shouldn't your data be a tuple ("1", dt)], not three?

regards
-----------------------------------------------------------------------
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------








More information about the Python-list mailing list