LiteScript don't create trigger

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Tarifer
Posts: 21
Joined: Thu 26 May 2011 08:13

LiteScript don't create trigger

Post by Tarifer » Thu 16 Aug 2012 14:56

Hello!
I have the script:

Code: Select all

CREATE TRIGGER TR_DETAIL_FILES
AFTER UPDATE OF PERIOD_DATE_STAMP, IS_ACTIVE ON DETAIL_FILES
FOR EACH ROW
BEGIN
	UPDATE CALLS 
	SET DETAIL_FILE_IS_ACTIVE=NEW.IS_ACTIVE,
		DETAIL_FILE_PERIOD_DATE_STAMP=NEW.PERIOD_DATE_STAMP
	WHERE DETAIL_FILE_ID=NEW.DETAIL_FILE_ID;
END;
When I run it in LiteScript, it execute only part of trigger (as DBMonitor shows):

Code: Select all

CREATE TRIGGER TR_DETAIL_FILES
AFTER UPDATE OF PERIOD_DATE_STAMP, IS_ACTIVE ON DETAIL_FILES
FOR EACH ROW
BEGIN
	UPDATE CALLS 
	SET DETAIL_FILE_IS_ACTIVE=NEW.IS_ACTIVE,
		DETAIL_FILE_PERIOD_DATE_STAMP=NEW.PERIOD_DATE_STAMP
	WHERE DETAIL_FILE_ID=NEW.DETAIL_FILE_ID
Please fix it.

Thanks,
Dmitry Ukolov.

ZEuS
Devart Team
Posts: 236
Joined: Thu 05 Apr 2012 07:32

Re: LiteScript don't create trigger

Post by ZEuS » Fri 17 Aug 2012 06:56

The TLiteScript component is intended for executing multiple SQL-statements. Each statement in the script is separated by the delimiter that is defined in the TLiteScript.Delimiter property. By default, the TLiteScript.Delimiter property is set to a semicolon character.
So, in your example the TLiteScript component treats the SQL-statement as two separate statements and tries to execute them in consecutive order.
In order to execute multiple SQL-statements that contain a semicolon, you should set the TLiteScript.Delimiter property to a value, other than a semicolon, for example to a slash character (/), and separate SQL-statements in a script using this delimiter.
Also, to obtain more information about using the TLiteScript component, please refer to the LiteDAC documentation.

Tarifer
Posts: 21
Joined: Thu 26 May 2011 08:13

Re: LiteScript don't create trigger

Post by Tarifer » Fri 17 Aug 2012 09:20

Thanks, it works.

Post Reply