When should the colon (:) character be used in procedure or trigger code?


The colon character should only be used to prefix variables in SQL statements. It is not needed to use it for simple assignments, and sometimes even not desirable. It is never used for 'new.' and 'old.' values in triggers as 'new' and 'old' are relations valid in both SQL and PSQL expression evaluation. Example:

create procedure p1 ( x integer )
as
declare variable y integer;
BEGIN
select emp_id from employee where emd_id = :x into :y;
if (y > 20) then y = x * 12;
update t1 set my_num = :y where id = :x;
END


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