You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firebird 3 introduced PSQL FUNCTION's and now it is recommended to convert UDF's into PSQL functions when possible.
ALTER FUNCTION statement could convert UDF into PSQL functions but sometime PSQL function become unusable after
such conversion. Example:
a) declare UDF
declare external function sright
varchar(100) by descriptor, smallint,
varchar(100) by descriptor returns parameter 3
entry_point 'right' module_name 'fbudf';
b) make sure it works
select sright('function', 2) from rdb$database;
SRIGHT
on
c) convert UDF into PSQL function
commit;
set term ^;
alter function sright (str varchar(100), len int)
returns varchar(100)
as
begin
return right(str, len);
end^
set term ;^
d) check if it works
select sright('function', 2) from rdb$database;
Statement failed, SQLSTATE = 07001
Dynamic SQL Error
-Input parameter mismatch for function SRIGHT
The problem is that ALTER FUNCTION didn't changed RDB$FUNCTIONS.RDB$RETURN_ARGUMENT value :
a) original UDF
select rdb$return_argument from rdb$functions
where rdb$function_name = 'SRIGHT';
RDB$RETURN_ARGUMENT
3
select rdb$argument_position, rdb$argument_name from rdb$function_arguments
where rdb$function_name = 'SRIGHT';
2do: check result of fb_run when issue related "GetThreadId could not be located in the dynamic link library KERNEL32.dll" will be fixed on Win XP (see letter to dimitr, hvlad 18.03.2018)
The text was updated successfully, but these errors were encountered:
Test Details: 2do: check result of fb_run when issue related "GetThreadId could not be located in the dynamic link library KERNEL32.dll" will be fixed on Win XP (see letter to dimitr, hvlad 18.03.2018)
Submitted by: @hvlad
Firebird 3 introduced PSQL FUNCTION's and now it is recommended to convert UDF's into PSQL functions when possible.
ALTER FUNCTION statement could convert UDF into PSQL functions but sometime PSQL function become unusable after
such conversion. Example:
a) declare UDF
declare external function sright
varchar(100) by descriptor, smallint,
varchar(100) by descriptor returns parameter 3
entry_point 'right' module_name 'fbudf';
b) make sure it works
select sright('function', 2) from rdb$database;
SRIGHT
on
c) convert UDF into PSQL function
commit;
set term ^;
alter function sright (str varchar(100), len int)
returns varchar(100)
as
begin
return right(str, len);
end^
set term ;^
d) check if it works
select sright('function', 2) from rdb$database;
Statement failed, SQLSTATE = 07001
Dynamic SQL Error
-Input parameter mismatch for function SRIGHT
The problem is that ALTER FUNCTION didn't changed RDB$FUNCTIONS.RDB$RETURN_ARGUMENT value :
a) original UDF
select rdb$return_argument from rdb$functions
where rdb$function_name = 'SRIGHT';
RDB$RETURN_ARGUMENT
select rdb$argument_position, rdb$argument_name from rdb$function_arguments
where rdb$function_name = 'SRIGHT';
RDB$ARGUMENT_POSITION RDB$ARGUMENT_NAME
===================== ===============================
1 <null>
2 <null>
3 <null>
b) after ALTER FUNCTION
select rdb$return_argument from rdb$functions
where rdb$function_name = 'SRIGHT';
RDB$RETURN_ARGUMENT
select rdb$argument_position, rdb$argument_name from rdb$function_arguments
where rdb$function_name = 'SRIGHT';
RDB$ARGUMENT_POSITION RDB$ARGUMENT_NAME
===================== ===============================
0 <null>
1 STR
2 LEN
Commits: cc2b19e f6e93ff
====== Test Details ======
2do: check result of fb_run when issue related "GetThreadId could not be located in the dynamic link library KERNEL32.dll" will be fixed on Win XP (see letter to dimitr, hvlad 18.03.2018)
The text was updated successfully, but these errors were encountered: