I need to copy a stored procedure from one Firebird database (v2.5.9) to other Firebird database (v5.0.1), but I don't have the source code. With isql I can extract the BLR of the stored procedure, and I was wondering if there is a way to create the stored procedure in the second database using only the BLR code.
In theory yes, in practice, no. For the following reasons:
Assuming the original author of the stored procedure deleted the source code from the RDB$PROCEDURE_SOURCE
column, and they refuse to hand over the code, the best thing you can do is view the BLR by casting to a BLOB SUB_TYPE TEXT (which will generate a "human readable" representation of the BLR), and use that to try and reverse engineer the stored procedure.
Alternatively, you could try and upgrade a copy of that Firebird 2.5 database using gbak (backup and restore), and instead copy the data of the other database into that database, so you have access to the stored procedure.