What is ASTA?
ASTA stands for A Smart Thin Architecture and is a Delphi technology that is leveraged by the WebPoint scripting language to connect to Firebird database's via Intouch's Data Server application.
This system provides developers with a method of connecting to databases without authentication, requiring only the use of an IP address or server name and the port number that the database is currently running on.
The ASTA system is very robust and allows for the implementation of both transactional and none transaction queries to be executed via the WebPoint scripting language.
How do ASTA transactions work?
With the ASTA system, database reads (selects) are forwarded immediately to the database, in order to query the data, whether there is an explicit transaction in place or not.
Please Note: ASTA transactions <> Firebird transactions.
When there is no explicit (ASTA) transaction started, any ExecSQL statement, or Execute on a Stored Procedure, is forwarded immediately to the database, and processed in sync with the select statements, in the order you would expect.
When an ASTA transaction is started, it then caches all ExecSQL and Execute statements, not sending them to the database (which means that any value that they insert or change will NOT be readable by any subsequent Select statements until the ASTA transaction is committed.) When the ASTA transaction is finalised, the action depends upon the value passed to EndTransaction - if the parameter is false, then the queued statements are simply discarded, and there has been no effect on the database.
If the parameter is true, then all the statements are forwarded to the server, and applied within one single Firebird transaction. If there is any error, the Firebird transaction is rolled back, and an exception raised (passed back to the client) to communicate what went wrong, with the result that nothing is changed in the database. If there are no errors, then the entire transaction is committed to the database, and everything proceeds as usual.
This system makes it possible to "queue up" many SQL statements, and execute them as a block within the one transaction, ensuring that they are all committed or not committed - atomic in other words.
This differs quite a lot from the standard transaction processing that is built into Firebird - where any updates made to the database within a single transaction are visible to subsequent select statements within the same transaction. This system requires two-way coordinated communication between the client and the server, something that is not a requirement for the ASTA system (where you could queue up 1000 insert/update statements without a connection to the database, then connect, send them all off and wait for the response, in one single round-trip operation).
While the "Firebird" handling is definitely more traditional, the ASTA mechanism is also valid but works on a different "model" than most people familiar with transactional databases would be used to. It does help to understand this model when programming with the ASTA system.
In summary;
With NO ASTA transaction, all update/insert SQL statements are processed immediately against the database, with each statement run in a separate Firebird transaction. Subsequent select statements will see the submitted data immediately. And there is no rollback possible across multiple SQL statements.
With an ASTA transaction started, all update/insert SQL statements are cached and submitted/committed in a single Firebird transaction when the transaction is finalised. Select SQL statements performed prior to the finalization will not see any submitted data.
|
|
|