Hi,
In a local form executed in Offline mode (airplane mode), I display some form elements bound to values of an SQLite table. I can modify the values of these form elements, so values in the SQLite table are automatically updated.
If by mistake I clear the values of some form elements (salary, address…), how can I undo these changes and redisplay the original values?
In RPG or LANSA, has somebody tried solutions like:
• SQLite transactions with commit/rollback,
• Intermediate table or Temporary table,
• Other…
Regards,
Yann
Undo changes on form elements and SQLite
-
tsupartono
- Posts: 289
- Joined: Wed Apr 18, 2012 10:21 am
Re: Undo changes on form elements and SQLite
Currently there is no mechanism that would do that automatically for you.
One approach is to use temporary table when in edit mode:
One approach is to use temporary table when in edit mode:
- Copy the record being edited to the temporary table.
Bind that temporary record to the elements.
Upon save, copy that record to the actual table, or do nothing if user selected cancel.
Re: Undo changes on form elements and SQLite
Thanks Tony,
To use a Temporary table, I suppose I have to define it in LongRange Studio and check its 'Temporary table' checkbox.
But I don't know how a Temporary table works within LongRange:
- What is its scope of life, i.e. when is it created, deleted?
- Do I have to manually delete records I have added in the table or is the table automatically cleared and when?
Regards,
Yann
To use a Temporary table, I suppose I have to define it in LongRange Studio and check its 'Temporary table' checkbox.
But I don't know how a Temporary table works within LongRange:
- What is its scope of life, i.e. when is it created, deleted?
- Do I have to manually delete records I have added in the table or is the table automatically cleared and when?
Regards,
Yann
-
tsupartono
- Posts: 289
- Joined: Wed Apr 18, 2012 10:21 am
Re: Undo changes on form elements and SQLite
In this case, it does not actually really matter if you define the table or "temporary" table or not in Studio, as you would only be keeping one row in your temporary table (that is, you would be keeping the row the user is currently editing) - so you can just delete all the rows in the temporary table before inserting a new row.
For example, if you have an EMPLOYEE table, and you want to make a copy of a row the user is currently editing, you can create another table called EMPLOYEE_TEMP.
To copy the current record to the EMPLOYEE_TEMP table (first clearing the EMPLOYEE_TEMP table):
To copy the record from EMPLOYEE_TEMP back to EMPLOYEE table (use REPLACE INTO):
For example, if you have an EMPLOYEE table, and you want to make a copy of a row the user is currently editing, you can create another table called EMPLOYEE_TEMP.
To copy the current record to the EMPLOYEE_TEMP table (first clearing the EMPLOYEE_TEMP table):
Code: Select all
DELETE FROM EMPLOYEE_TEMP;
INSERT INTO EMPLOYEE_TEMP(ROWID, EMPNO, NAME) SELECT ROWID, EMPNO, NAME FROM EMPLOYEE WHERE ROWID = &(FLD:ROWID);
Code: Select all
REPLACE INTO EMPLOYEE(ROWID, EMPNO, NAME) SELECT ROWID, EMPNO, NAME FROM EMPLOYEE_TEMP;
Re: Undo changes on form elements and SQLite
Very interesting.
My last question will be: in Studio, what is the purpose of the 'Temporary table' checkbox?
My last question will be: in Studio, what is the purpose of the 'Temporary table' checkbox?
-
tsupartono
- Posts: 289
- Joined: Wed Apr 18, 2012 10:21 am
Re: Undo changes on form elements and SQLite
Table indicated as 'temporary' in Studio will have its content automatically erased when the database becomes free (that is, when no forms or operations are referring to the database).