I'm migrating from SQL Server to Firebird.
In SQL Server
CREATE PROCEDURE Departments_GetAll
AS
SELECT * FROM Departments
I try in Firebird
CREATE PROCEDURE DEPARTMENTS_DELETEALL
AS
BEGIN
SELECT * FROM "Departments";
END^
SET TERM ; ^
But that doesn't work.
It returns an error "SQL Code -104"
Right click on stored procedure in the Object Explorer and select Refresh. You will see the SP is created. Now, Right click on SP name and select Execute stored procedure…. Provide the input values and execute.
We can not directly use stored procedures in a SELECT statement.
Expand Stored Procedures, right-click the procedure and then select Script Stored Procedure as, and then select one of the following: Create To, Alter To, or Drop and Create To. Select New Query Editor Window. This will display the procedure definition.
A stored procedure needs return parameters and the suspend
command in order to return multiple rows.
CREATE PROCEDURE DEPARTMENTS_GET_ALL
returns(id integer, name varchar(100))
AS
BEGIN
FOR SELECT id, name
FROM "Departments"
into :id, :name do
BEGIN
SUSPEND;
END
END^
SET TERM ; ^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With