Hi Tuvia,
After further research we came up with the following code updates;
could you review and provide feedback on your testing?
If this is OK for cursors, we'll need to implement for restoration of buffered data in aliases having autoincremented fields.
Thanks,
* ------------------------------------------------------------HIDDENPROCEDURE PropsRestore_DS_Alias_data_rowsLPARAMETERS tcTypeIF m.tcType == 'C'&& seul le contenu des curseurs est à restaurerIFIsReadonly() && {V 1.26} ne devrait plus jamais arriver puisque this.PropsRestore_DS_Alias_cols() force à READWRITE this.Warning(Textmerge([() - ] + ICase(; m.this.cLangUser = 'fr', [Le curseur '' est en lecture seule - veuillez utiliser la clause INTO CURSOR ,; && copy-paste this line to add another language support[Cursor 'avec la clause READWRITE] ' is read-only - please use clause INTO CURSOR ; )))ELSELOCAL loRows AS MSXML2.DOMDocument, lcCursor, lcAlterPre, lcAlterPost loRows = this.PropsRestore_DS_oChildNode('rows') lcCursor = this.PropsRestore_DS_Alias_cXMLcursor(m.loRows.XML, @m.lcAlterPre, @m.lcAlterPost)ZAP&& nécessite CursorGetProp("Buffering") <= 3&lcAlterPreAPPENDFROMDbf(m.lcCursor)&lcAlterPost USE IN (m.lcCursor) ENDIFENDIFwith the READWRITE clause]
* ------------------------------------------------------------HIDDENPROCEDURE PropsRestore_DS_Alias_cXMLcursor && Curseur chargé avec les données XMLLPARAMETERS ; tcXML,; && XML to be loaded tcAlterPre,; && @ [''] ALTER TABLE command before loading cursor to turn off autoincrementing field(s) tcAlterPost && @ [''] ALTER TABLE command after loading cursor to restore autoincrementing field(s)STORE''TO tcAlterPre, tcAlterPostLOCAL laField[1], laField_[1], lnField, liField, lcField, liAutoInc; , loSelect, lcAlias; , lcResult#IF .F. && AFields()&& cursor? # contents type Yes 01 Fieldname Character Yes 02 Fieldtype Character Yes 03 Fieldwidth Numeric Yes 04 Decimal places Numeric Yes 05 Null values allowed Logical Yes 06 Code page translation not allowed Logical Yes 07 Field validation expression Character Yes 08 Field validation text Character Yes 09 Fielddefaultvalue Character No 10 Table validation expression Character && Values for table-specific properties in columns 10 through 16 only appear in the first row of the array No 11 Table validation text Character No 12 Long tablename Character No 13 Inserttrigger expression Character No 14 Update trigger expression Character No 15 Deletetrigger expression Character No 16 Table comment Character Yes 17 NextValue for autoincrementing Numeric Yes 18 Stepfor autoincrementing Numeric && If the fields in the table use autoincrementing, the Step value is greater than 0#ENDIF* As CursorToXML() does not render .NULL. values,* create a cursor in which all fields have .NULL. as default value,* except autoincrementing fields which must retrieve their former sequence lnField = AFields(laField) lnField = AFields(laField_) && backupFOR liField = 1 TO m.lnField lcField = laField[m.liField, 1]IF laField[m.liField, 18]> 0 && If the fields in the table use autoincrementing, the Step value is greater than 0 laField[m.liField, 18] = 0 && turns off autoincrementing on this field, while accepting values from XML tcAlterPre = m.tcAlterPre + Textmerge(" ALTER COLUMN <<m.lcField>> I")ELSEIF laField[m.liField, 5]&& Null values allowed laField[m.liField, 9] = Evl(laField[m.liField, 9], '.NULL.') && Field default value as litteralENDIFENDIFENDFOR lcAlias = Alias() lcResult = m.lcAlias + '_XML' loSelect = abSelect(0)CREATECURSOR (m.lcResult) FROMARRAY laField && changes work areaXMLToCursor(m.tcXML, m.lcResult, 8192)&& 8192:&& Specifies that cCursorName is the name or alias of an existing table or cursor&& and imports the data from the specified XML file into an existing table or predefined cursor.&& If cCursorName contains data, the data imported from the XML file is appended to the existing data* For each autoincrementing field, calculate next value and restore auto-incrementationFOR liField = 1 TO m.lnFieldIF laField_[m.liField, 18]> 0 && If the fields in the table use autoincrementing, the Step value is greater than 0 lcField = laField_[m.liField, 1]CALCULATEMax(&lcField) TO liAutoInc tcAlterPost = m.tcAlterPost + Textmerge(" ALTER COLUMN <<m.lcField>> I AUTOINC NEXTVALUE <<m.liAutoInc + laField_[m.liField, 18]>> STEP <<laField_[m.liField, 18]>>")ENDIFENDFORIF NOT Empty(m.tcAlterPre) tcAlterPre = Textmerge([ALTER TABLE <<m.lcAlias>><<m.tcAlterPre>>])ENDIFIF NOT Empty(m.tcAlterPost) tcAlterPost = Textmerge([ALTER TABLE <<m.lcAlias>><<m.tcAlterPost>>])ENDIFRETURN m.lcResult