The following procedure describes:
SET TERM !!;
CREATE PROCEDURE concat_names
RETURNS (concat VARCHAR(2000))
AS
DECLARE VARIABLE name VARCHAR(100);
BEGIN
concat = '';
FOR SELECT first_name || ' ' || last_name FROM employee INTO :name
DO BEGIN
concat = concat || name || ', ';
END
END!!
SET TERM ;!!
EXECUTE PROCEDURE concat_names;
But I doubt the wisdom of this decision. How do you know that VARCHAR is long enough for all rows in your desired dataset?
It is much easier and safer to run a query to return the result to the application line by line. Each application programming language has string concatenation methods, but more importantly, they have more flexible methods for managing data growth.
By the way, the “dialect” in Firebird and InterBase refers to the compatibility mode that was introduced so that applications developed for InterBase 5.x can work with later versions of InterBase and Firebird. That was almost ten years ago, and AFAIK does not need to use anything below dialect 3 today.
source
share