Python cx_Oracle merge mystery - working in SQL Dev not working in python33 -


i using python33 , cx_oracle (with oracle 11g) analyze database, have run problem. problem sql: merge ftab01 using (select username , count (case when action ='friend' 1 end) friendcount pool_1 group username) b on (a.username=b.username) when matched update set a.friendcount=b.friendcount if run command in sql developer, works perfectly, if this: cursor.execute("merge ftab01 using (select username , count (case when action ='friend' 1 end) friendcount pool_1 group username) b on (a.username=b.username) when matched update set a.friendcount=b.friendcount"), fail (without error! - not change table). other commands working (for example: cursor.execute('alter table '+self.tabname + ' add ('+column_name+' number)') - code 2 lines above problematic code. have no idea might wrong, tried googling longer time haven't found (maybe because don't know how name problem)

code used it:

def action_counts(self,action_list): sql = "merge "+self.tabname + " using (select username " sql_when_matched =""; action in action_list:   column_name = (action+'count').replace('-','_')   print(column_name)   sql += ", count (case when action ='"+action+"' 1 end) "+column_name   sql_when_matched += " a."+column_name+"=b."+column_name+", "   cursor.execute('alter table '+self.tabname + ' add ('+column_name+' number)') sql += " pool_1 group username) b on (a.username=b.username) when matched update set "+sql_when_matched sq2 = sql.rstrip().rstrip(",") print(sq2) cursor.execute(sq2)  #this printed sq2 , copy-pasted execute() (and if copy-pasted sql developer working properly) cursor.execute("merge ftab01 using (select username , count (case when action ='friend' 1 end) friendcount pool_1 group username) b on (a.username=b.username) when matched update set  a.friendcount=b.friendcount") 

since not produce error message have no idea wrong, appreciated.

are commiting update? depending on version of oracle alter table may autocommitted merge may rolled back.

try adding:

connection.commit() 

after merge , see if works.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -