[vxcmd] Cursor_AddRecords mangles field content

Robert Brenstein rjb at rz.uni-potsdam.de
Mon Jun 14 11:52:53 CDT 2004


I know you are focused on 2 and hate to deal with bugs in 1 but here 
is one for you.

I have a function that relies on Cursor_AddRecords to duplicate a set 
of records in a table 'boName'. This function is used to duplicate 
all records associated with a given item when users duplicate an 
existing database entry -- the program loops through all associated 
bo's duplicating appropriate records.

I have been using it for a few years. However, it has always 
sporadically produced bogus results -- content of fields was messed 
up. This was hard to nail down because each bo has different 
structure and number of fields, some required and some optional.

I kept repairing this by hand but I think I have finally realized why 
the data is mangled: some of the field values fetched by 
Database_SQLSelectRecords are empty (which is valid). However, those 
empty values make Cursor_AddRecords to shift the content between 
fields. At first glance, it seems to simply skip the empty input and 
pick the next value in the list. The last value is filled with 
something random, usually left empty.

Here is my function (sans error checking to make reading easier) in 
case you want to see the usage. You could add this to your testing 
suite as well, Ruslan.  This is very efficient way to clone entries.

on doDupBo boName, refFld,idOld,idNew,refCol
   --  duplicate a set of records from a single baseobject while 
changing their course ref
   set the itemDelimiter to tab
   put "SELECT * FROM" && boName && "WHERE" && refFld && " = " & idOld 
into query
   put Valentina("Database_SQLSelectRecords",dbName, query) into boKurs
   if boKurs is empty then return empty -- nothing to do
   put "SELECT * FROM" && boName && " WHERE recid = 0" into query
   put Valentina("DataBase_SQLSelect",DbName,query) into crs
   repeat with i=1 to the number of lines of boKurs
     put idNew into item refCol of line i of boKurs
   end repeat
   put Valentina("Cursor_AddRecords",crs,boKurs) into ur
   get Valentina("Cursor_Remove",crs)
end doDupBo

It seems to be a bug in xcmd interface.

Robert Brenstein


More information about the Valentina mailing list