How to SELECT a PROCEDURE in Firebird 2.5

前端 未结 8 1347
误落风尘
误落风尘 2021-01-11 23:21

I\'m using Firebird Embedded v2.5. How to use procedures in query (SELECT) ?

My procedure:

SET TERM ^ ;
CREAT         


        
相关标签:
8条回答
  • 2021-01-11 23:51

    FN_TEST is an executable procedure: it can be called via the EXECUTE PROCEDURE statement and it returns a single set of output parameters.

    In Firebird 2.x only a selectable stored procedure can be "used" as a view / table (see Firebird Stored Procedures).

    So:

    SELECT FN_TEST(some_table_field) AS field_modified
    FROM   tb_test
    

    produces an invalid request BLR at offset... error.

    You could change your procedure as suggested but, actually, the feature you need has been introduced in Firebird 3 in the form of stored function:

    CREATE FUNCTION FN_TEST(Y INT) RETURNS INT
    AS
    BEGIN
      RETURN Y + 1;
    END;
    
    SELECT FN_TEST(4) AS zzz
    FROM   tb_test
    

    Further details in Functions with PSQL in Firebird 3.

    0 讨论(0)
  • 2021-01-11 23:51

    Use UDF in order to manage calculation on fields. Stored procedure are admited only in the FROM Clause.

    0 讨论(0)
提交回复
热议问题