Hello,
I have the following scenario where I need to create (almost) clone records on a table (only the record id and another field will be different). I am using SQL Server 2019 as the database.
I have a table called grow with the following fields:
- id (added by Jam, it is an integer autoincremented field - not shown to the user)
- afm (text)
- name (text)
- year (integer, lookup to another table called years, maps to field id which is integer auto-incremented).
From the server side, I have the following function to create clone records with different year value (the new lookup value already exists on the years table). The function is succesfully called from the client, the error appears on the server side.
def clone_grow(item, yearfrom, yearto):
...
...
cgto = item.task.grow.copy()
cgto.set_where(year=yearto) # there is the possibility that there are no records already
cgto.open(open_empty=True)
cgfrom = item.task.grow.copy()
cgfrom.set_where(year=yearfrom) # we have records
cgfrom.open()
while not cgfrom.eof():
cgto.append()
cgto.year.value = yearto # the new record is for the new year id
cgto.afm.value = cgfrom.afm.value
cgto.name.value = cgfrom.name.value
cgfrom.next()
cgto.apply()
After executing the code, the following error appears:
I am probably doing something stupid, can someone provide any hints why this is not working?
Many thanks in advance.
Best regards,
Manos Pappas