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

Steve Holden sholden at holdenweb.com
Wed Jun 5 11:56:28 EDT 2002


"Jim" <jtt at hnc.com> wrote in message
news:be0d725a.0206050557.1592bc3b at posting.google.com...
> Here is better version of the same program.  Sorry for last posting.
>
> ! /usr/bin/env python
> import DCOracle2
> #*************************************************************
> # Define variables and constants
> #*************************************************************
> TRUE = 1
> FALSE = 0
> FalconPwd = 'uid/pwd'
> Results_count = 0
> db = DCOracle2.connect(FalconPwd)
> #
> # Open a new cursor
> #
> dbCursor = db.cursor()
> tran_date = '19970116124248'
> 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_count = DCOracle2.execute(dbCursor,'select * from
> falcon.falt002d where ACCT_NBR = :1 and trn_dt = :2',"2222222222222222
>   ",dt)
>
>
> tabledata = dbCursor.fetchone()
>
> print tabledata

1. Is there any reason why you are using "DCOracle2.execute(dbCursor..."
rather than "dbCursor.execute(..."? You should really be calling teh
cursor's method (assuming the DCOracle2 module follows the DB API
recommendations).

2. Is there any reason why you are using '"2222222222222222",dt)' rather
than '("2222222222222222",dt))' - teh DB PAI suggests execute() should take
two arguments, the first a SQL statement and the second an (optional) tuple
of substitutions.

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








More information about the Python-list mailing list