Subject | How to return a string from a stored procedure? |
---|---|
Author | firebirdsql |
Post date | 2011-09-07T00:33:28Z |
I have a stored procedure that stores some dynamic sql in a string (this is just an example):
CREATE PROCEDURE test RETURNS (return_variable AS VARCHAR(1000))
FOR
SELECT 'SELECT username FROM users ' FROM username INTO :return_variable
DO SUSPEND;
END
If I then run it:
SELECT return_variable
FROM test ;
Instead of returning
'SELECT username FROM users SELECT username FROM users SELECT username FROM users'
It returns 3 rows of 'SELECT username FROM users'. How do I get it to return a single string?
CREATE PROCEDURE test RETURNS (return_variable AS VARCHAR(1000))
FOR
SELECT 'SELECT username FROM users ' FROM username INTO :return_variable
DO SUSPEND;
END
If I then run it:
SELECT return_variable
FROM test ;
Instead of returning
'SELECT username FROM users SELECT username FROM users SELECT username FROM users'
It returns 3 rows of 'SELECT username FROM users'. How do I get it to return a single string?