What are those SET TERM statements?


SET TERM is used by isql, FlameRobin and some other tools to change the statement terminator (TERM is short for Terminator). It is neccessary for triggers, stored procedures and execute block statements.

The reason is that the default statement terminator is semi colon (;). However, procedures and triggers contain multiple statements within, so the statement parser would stop there. Consider this example:

create procedure p1
as
begin
insert into t1 values(10);
end;

The parser would stop right after (10) and it would yield an incomplete statement. With SET TERM we change the terminator to something else, preferably a character (or characters) never used anywhere in the procedure or trigger body:

SET TERM ^ ;
create procedure p1
as
begin
insert into t1 values(10);
end^

Notice how we terminate the statement with ^ and semicolon is completely ignored.

It is a common practice to set the terminator back to semicolon after statement, to prevent problems with subsequent statements.

SET TERM ; ^

When parser parses that, it reads just "SET TERM ;" as ^ is a terminator and not included in the statement. So it's set back to semi-colon.


Do you find this FAQ incorrect or incomplete? Please e-mail us what needs to be changed. To ensure quality, each change is checked by our editors (and often tested on live Firebird databases), before it enters the main FAQ database. If you desire so, the changes will be credited to your name. To learn more, visit our add content page.



All contents are copyright © 2007-2024 FirebirdFAQ.org unless otherwise stated in the text.


Links   Firebird   News   FlameRobin   Powered by FB: Home Inventory   Euchre  
Add content   About  

Categories
 Newbies
 SQL
 Installation and setup
 Backup and restore
 Performance
 Security
 Connectivity and API
 HOWTOs
 Errors and error codes
 Miscellaneous