By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,275 Members | 1,921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,275 IT Pros & Developers. It's quick & easy.

cx_oracle: How do you pass variable value in placeholder with OFFSET clause in python

P: 1
Hi ,
Whenever trying run below code , i am getting error " cur.execute("select * from nm_src_lkup ORDER BY NM_SRC_CD OFFSET :row_count ROWS") cx_Oracle.DatabaseError: ORA-01008: not all variables bound" . i am passing rowcount variable value in OFFSET cluase with select query .but it's not working .Please help me out
Expand|Select|Wrap|Line Numbers
  1. from time import sleep
  2. import sys
  3. import cx_Oracle
  4. import csv
  5. IDLE_INTERVAL_IN_SECONDS = 100
  6. dsn_tns = cx_Oracle.makedsn('xxxx.com', '1521', service_name='ppxxx.com') 
  7. conn = cx_Oracle.connect('MDBSE','mdbB5se', dsn=dsn_tns)
  8. cur = conn.cursor()
  9. row_count = 0
  10. while True:
  11.     cur.execute("select * from nm_src_lkup ORDER BY NM_SRC_CD OFFSET :row_count ROWS")
  12.     row_count = cur.rowcount
  13.     if row_count > 0:
  14.         file = open("skp1.csv","w")
  15.         output = csv.writer(file , dialect='excel')
  16.         for row_data in cur:
  17.         output.writerow(row_data)
  18.     sleep(IDLE_INTERVAL_IN_SECONDS)
  19.  
Jan 20 '20 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.