Jump to content
Sign in to follow this  
Henry Olive

Firebird 4.0 UDF

Recommended Posts


I wish everyone a healthy day.
 

In my data path there are udf.sql, udflib.c, udflib.def  files

I copied below code from Firebird's  udf.sql
when i try to execute below code in Flame Robin

I'm getting  CREATE FUNCTION SUBSTR failed
unknown ISC error 336068876
 

DECLARE EXTERNAL FUNCTION substr 
    CSTRING(256), SMALLINT, SMALLINT
    RETURNS CSTRING(80) FREE_IT
    ENTRY_POINT 'fn_substr' MODULE_NAME 'udflib'

 

What is wrong ?
Thank You

 

Share this post


Link to post

Hi,

First, know that :

  1. there are many internal functions in Firebird SUBSTR should be replaced advantageously by SUBSTRING (even if a little more "verbose" syntax)
  2. Udf are deprecated in Firebird 4.0 (P.S. don't ask me about UDR, I am still with 2.5 in production, 3 running only for test, 4 only installed)
  3. read 5.10 chapter of Firebird 4.0 Language reference

 

In my mind, Firebird 3 is  closer Interbase

For the declaration of the UDF, I think you have to first check firebird .conf file (default parameter “UdfAccess” set to “None” ) , 

 

UDFs directories and bitness  of the library also involved

Edited by Serge_G
  • Like 1

Share this post


Link to post

Thank you so much Serge


firebird.conf  file says below message


NOTE: THE EXTERNAL FUNCTION ENGINE FEATURE COULD BE USED TO COMPROMISE
# THE SERVER/HOST AS WELL AS DATABASE SECURITY!!
# IT IS STRONGLY RECOMMENDED THAT THIS SETTING REMAINS NONE!

Any advice to use SUBSTR function ?

Thank You
 

Share this post


Link to post

firebird .conf says
 

# ----------------------------
# External Function (UDF) Paths/Directories
#
# UdfAccess may be None, Full or Restrict. If you choose
# Restrict, provide ';'-separated trees list, where UDF libraries
# are stored. Relative paths are treated relative to the root directory
# of firebird.
#
# Since FB4.0 default value is None. Set it to 'Restrict UDF' to have
# the same restrictions as in previous FB versions. To specify access
# to specific trees, enum all required paths (for Windows this may be
# something like 'C:\ExternalFunctions', for unix - '/db/udf;/mnt/udf').
#
# NOTE: THE EXTERNAL FUNCTION ENGINE FEATURE COULD BE USED TO COMPROMISE
# THE SERVER/HOST AS WELL AS DATABASE SECURITY!!
#
# IT IS STRONGLY RECOMMENDED THAT THIS SETTING REMAINS NONE!
#
# Type: string (special format)
#
#UdfAccess = None

First change is to uncomment (removing #) last line and say UdfAccess = Restrict UDF  as wrote line 10 (pointing the dir_udf directory C:\Program Files\Firebird\Firebird_4 _0\UDF)  or indicate directories like indicated below line 10 

UdfAcess=C:\interbase\UDF;C:\MyUDF ....

 

If you make a non customed  install of Firebird 4.0 you should see the UDF directory don't exist, and no udflib dll copied

 

AS I said if you want a near Interbase Firebird use version 3

 

 

 

Edited by Serge_G

Share this post


Link to post
5 hours ago, Henry Olive said:

Any advice to use SUBSTR function ?

 

Use SUBSTRING instead of SUBSTR, as Serge_G wrote...

Edited by Vandrovnik
  • Like 1

Share this post


Link to post
On 11/16/2021 at 12:40 PM, Henry Olive said:

Thank you SO MUCH  Serge, Vandrovnik

SUBSTRING solves my problem
 

Interbase has virtually no internal functions. Not even in the newest versions. All has to be done in UDFs. The Firebird developers on the other hand had changed that from the beginning.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×