* optimistic methods - assume a situation where the majority of
database operations do NOT conflict
* transaction moves through 3 phases:
* read phase: transaction reads the database, executes the
needed computations BUT makes any updates to a PRIVATE copy
of the database values (only accessible by that transaction,
and not any others running concurrently)
* validation phase: the transaction is validated to make sure
its changes will not affect the database's integrity or
consistency;
* if validation succeeds, go to next phase
* if validation fails, then the transaction is
restarted, and its changes discarded
* write phase: permanently apply the changes to
the database
* suitable for a mostly-read, mostly-query, FEW-update
scenario;
==========
intro to PL/SQL and PL/SQL triggers
==========
PL/SQL - "procedural language" SQL -
Oracle's extension of SQL adding procedural structures
(if, loops) and other features (local variables, procedures,
functions) common to procedural programming languages
(looks very much to me as if it was influenced by the
family of programming languages that includes Ada...)
* to SEE the results of dbms_output.put_line calls,
make SURE you include:
set serveroutput on
...in your script OR your sqlplus session where you
want to see these outputs;
* in PL/SQL, you can write database objects such as
stored procedures, stored functions, and triggers
trigger: a module that is not directly called,
but is executed, or "triggered", by
some action on the database
it can be triggered BEFORE some action
(say, to prevent it if it is not actually OK
to go on with it)
it can be triggered AFTER some action
(say, to perform additional "cleanup" actions
on other tables that should be taken)
* basic simple syntax: [ for optional pieces ]
{ for CHOICES | of OPTIONS }
(not including ALL options...)
CREATE [OR REPLACE] TRIGGER trigger_name
{ BEFORE | AFTER }
{ DELETE | INSERT | UPDATE }
ON table_name
[FOR EACH ROW]
[DECLARE
local_var desired_type;
...
]
BEGIN
statements;
[EXCEPTION
...
]
END;
/ <---- YOU MUST HAVE THIS OR YOUR PL/SQL MODULE
WILL NOT COMPILE!!!!!!!!!!!!!!!!!!!!!!!!!!!