0

I am trying to use python to insert the data into oracle table using the below mentioned query:

cursor.execute("insert into tbl_test values (to_number('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'),to_char('{}'))".format(ID,NEW,PAYMENT,SID,AID,P_NUMBER,ASSIGNED_TO,CAL_DIS,CAL_SUB_DIS,CAL_SUB_SUB_DIS,BESTDIS,LANG,LOC,C_DATE,W_NMBR,WEEKDAY,OVERALL_DISP,PREPROCESS_SUB,CTABILITY,KWORDS,INFER,R_WORD,R_INFER,C0,C1,C2,C3,C4,C5,C6,C7,C8,C9))    
conn.commit()

DatabaseError: ORA-00907: missing right parenthesis

This query inserts the few rows of the data into the table but then gives "missing right parenthesis" error. Can you please let me know how to resolve this issue as I do not see any issue with the syntax in the code.

The SQL Loader file that was being used for this purpose is as follows:

LOAD DATA
INFILE 'D:\Data.csv'
append into table  
tbl_test
fields terminated by "," optionally enclosed by '"'
trailing nullcols
(ID, NEW  char(4000) , PAYMENT  char(4000) , SID  char(4000) , AID  char(4000) , P_NUMBER  char(4000) , ASSIGNED_TO  char(4000) , CAL_DIS  char(4000) , CAL_SUB_DIS  char(4000) , CAL_SUB_SUB_DIS  char(4000) , BESTDIS  char(4000) , LANG  char(4000) , LOC  char(4000) , C_DATE  char(4000) , W_NMBR  char(4000) , WEEKDAY  char(4000) , OVERALL_DISP  char(4000) , PREPROCESS_SUB  char(4000) , CTABILITY  char(4000) , KWORDS  char(4000) , INFER  char(4000) , R_WORD  char(4000) , R_INFER  char(4000) , C0  char(4000) , C1  char(4000) , C2  char(4000) , C3  char(4000) , C4  char(4000) , C5  char(4000) , C6  char(4000) , C7  char(4000) , C8  char(4000) , C9  char(4000))
Praveen
  • 415
  • 5
  • 9
Sumit
  • 13
  • 3
  • Hi Sunit. The insert statement seems ok to me. Can you please debug-out the resulting insert statement please? Let's see what's in it – ekochergin Apr 30 '21 at 12:37
  • Is there a reason you aren't using [bind variables](https://stackoverflow.com/a/33882805/266304)? – Alex Poole Apr 30 '21 at 13:12
  • @ekochergin Can you please let me know how can I debug out the resulting insert statement? – Sumit Apr 30 '21 at 13:51
  • @Sumit get everything you are passing to execute and output it with "print" or whatever name it is for output in pythons. Then paste the output here. – ekochergin Apr 30 '21 at 13:56

0 Answers0