I'm trying to solve the problem of intercepting records opened by clients for editing.
I am creating a procedure that should be called by a trigger when the database is opened and which will create a RAM table named REC_LOCK.
The table will contain the OIDs of records opened by clients for editing.
When a client saves a record, its reference is removed from the REC_LOCK table.
-- OID of the locked entry.
-- REC_UTS - timestamp.
-- REC_USR - who edits.
Also, I set the IO encoding to windows-1251
CREATE PROCEDURE "SET_ENV"()
BEGIN
SET @TXTSQL = 'CREATE TEMPORARY RAM TABLE IF NOT EXISTS REC_LOCK(
OID_REC ULLONG NOT NULL,
REC_UTS ULONG DEFAULT METHOD( ''unix_timestamp(now())'' ) NOT NULL,
REC_USR STRING ( 3 ) DEFAULT METHOD( ''current_user()'' ) NOT NULL );
SET PROPERTY IOEncoding OF DATABASE TO ''windows-1251'';';
EXECUTE @TXTSQL;
END
Is it possible to call a procedure that performs DDL statment from a trigger for opening a database?
CREATE TRIGGER START_DB AFTER STARTUP ON DATABASE
BEGIN
CALL "SET_ENV"();
END
=> Kernel Error: 0x91505. Trigger "START_DB": action "DB_StartUp " is not supported in this context.
The same for the AFTER LOGON ON DATABASE event.
What do you advise?
Perhaps the CREATE TRIGGER on DB
page should provide more detailed information, with examples of practical use.
I only managed to write something to the log, for example:
PRINT 'Ося и Киса были здесь!'
By the way, the example given on the CREATE TABLE page also not working
-- Starting with v5 you can also define TEMPORARY RAM fields.
-- This can be an interesting feature in combination with another new feature v5 - triggers on database event
CREATE TRIGGER trig_after_open_CreatePersonHas
AFTER STARTUP ON DATABASE
BEGIN
ALTER TABLE T ADD COLUMN fldMyHash FixedBinary(16) TEMPORARY RAM;
END
Firstly, the parser does not understand the RAM attribute for the field:
=> Kernel Error: 0x71000. line 4:66: expecting ';', found 'RAM' , although on page erformance:ram_objects" target="_blank" rel="nofollow">RAM Temporary Field this is presented as a unique opportunity for VDB.
But in fact, it is impossible add a RAM-field to a DISK-table, only temporary field, in «.tmp» volume
Secondly, even if we remove it, we will still get the same result:
=> Kernel Error: 0x91505. Trigger "trig_after_open_CreatePersonHas": action "DB_StartUp " is not supported in this context.
It may be worth correcting the documentation or making the stated capabilities work.