Forum

Forum breadcrumbs - You are here:ForumGeneral: Chit-chatSQL Quesstion
Please or Register to create posts and topics.

SQL Quesstion

PreviousPage 2 of 2

I'm sure it's a Python programming question which is kinda outside the scope of this forum and certainly outside my limited sphere of competency. My only suggestion is to bring the sql2 expression inside the FOR loop which increments step so that it is sure to be expanded with that value.

step = 0
sql1 = "SELECT * FROM tl_link WHERE tl_name_key = 2 ORDER BY tl_entry_seq"

cursor1 = connection.cursor()
cursor2 = connection.cursor()

for row in cursor1.execute(sql1):
sql2 = "UPDATE tl_link SET tl_entry_seq = " + str(step) + " WHERE tl_name_key = 2"
print("Step" , step, sql2)
cursor2.execute(sql2)
step = step + 10 # or maybe this goes right after the start of the FOR loop
...

 

PreviousPage 2 of 2