diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2023-11-23 17:59:33 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2023-11-24 09:54:59 +0100 |
commit | 9b5b313a2f2980f9a10295aabdd696f58af03302 (patch) | |
tree | 7bab5b261b6a430c64de209849b5f833acfc7e29 /wizards/source/sfdatabases/SF_Dataset.xba | |
parent | 9137bd2dd3ab66ffa783fc15a1add1e9cf541460 (diff) |
ScriptForge (SF_Database) manage transactions
Transactions are managed by next UNO properties:
XConnection.AutoCommit
XConnection.TransactionIsolation
(They seem very easy to use but, in practice,
are not easy at all)
Usually all transactions are in auto-commit mode,
that means, a commit takes place after each
single SQL command.
Switching auto-commit off means however that
the connection needs to be of type "ISOLATED"
and not of the default type "SHARED".
=> The usual shared connection must be closed.
As a consequence, all rowsets/resultsets linked
to the shared connection need to be closed as well.
=> Additionally the buffers must be emptied (flushed)
to make committed data visible in the Base user
interface.
All above aspects and constraints are managed in the
database.SetTransactionMode(transactionmode)
database.Commit()
database.Rollback()
methods transparently for the user scripts.
The [transactionmode] argument has as value one of
the TransactionIsolation constants.
Without argument, database.SetTransactionMode()
restores the automatic mode.
The manual transaction mode is available for both
Basic and Python scripts.
Its implementation will require an update of the
documentation about the Database service.
Change-Id: I214bd91a1744d6d24609bc5efc987152c6e946c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159867
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Diffstat (limited to 'wizards/source/sfdatabases/SF_Dataset.xba')
-rw-r--r-- | wizards/source/sfdatabases/SF_Dataset.xba | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/wizards/source/sfdatabases/SF_Dataset.xba b/wizards/source/sfdatabases/SF_Dataset.xba index 28091d9368b8..e9eb050d93f0 100644 --- a/wizards/source/sfdatabases/SF_Dataset.xba +++ b/wizards/source/sfdatabases/SF_Dataset.xba @@ -106,6 +106,8 @@ Private _UpdatableFields As Variant ' Array of updatable field names Private _DefaultValues As Variant ' Array of field default values // _Fields Private _AutoValue As Long ' Index of AutoValue field. None = -1 +Private _DatasetIndex As Long ' Index of the dataset in the _Datasets array of the parent database + REM ============================================================ MODULE CONSTANTS REM ====================================================== CONSTRUCTOR/DESTRUCTOR @@ -127,6 +129,7 @@ Private Sub Class_Initialize() _UpdatableFields = Array() _DefaultValues = Array() _AutoValue = -1 + _DatasetIndex = -1 End Sub ' SFDatabases.SF_Dataset Constructor REM ----------------------------------------------------------------------------- @@ -280,6 +283,7 @@ Try: .close() .dispose() End With + If _DatasetIndex >= 0 Then Set _ParentDatabase._Datasets(_DatasetIndex) = Nothing Dispose() bClose = True End If @@ -1350,8 +1354,11 @@ Try: If Len(sUpdatableFields) <= 1 Then _UpdatableFields = Array() Else _UpdatableFields = Split(Mid(sUpdatableFields, 2), ",") End With End With + + ' Insert the instance in the _Datasets array of the parent database + _DatasetIndex = _ParentDatabase._AddToDatasets([Me]) - bDataset = True + bDataset = ( _DatasetIndex >= 0 ) Finally: _Initialize = bDataset @@ -1661,4 +1668,4 @@ CatchError: End Function ' SFDatabases.SF_Dataset._SetColumnValue REM ============================================ END OF SFDATABASES.SF_DATASET -</script:module> +</script:module>
\ No newline at end of file |