Run custom scripts

Good afternoon. Please tell me how to add the script correctly. It is required before and after the backup to execute the script on the database, when I insert it into the query window and perform the backup, an error occurs.
Script:
create or replace function json_to_intarray(p_json json)
returns bigint[]
as
$$
begin
return null;
–case
–when p_json::text = ‘[]’
–then null
–when is_valid_json_array(p_json)
–then array(select * from (select try_cast(json_array_elements_text(p_json))::bigint v) v where not v is null)
–when not p_json is null
–then array(select * from (select try_cast(json_array_elements_text((’[’ || p_json || ‘]’)::json))::bigint) v where not v is null)
–else null
–end;
end;
$$
language plpgsql
immutable;Preformatted text

error:

Hello Alexsandr_M,

Thank you for the details.

Please give us some time to check the issue, we’ll keep you updated.

Thank you and sorry for the inconvenience.

Hello Alexsandr_M,

Thank you for your waiting.

We have checked the issue and noticed, that when executing the SQL script, there is a peculiarity where the application passes the script text as a parameter -c to the psql.exe utility, rather than executing it through the ODBC provider.

This may cause problems when executing multi-line scripts. We recommend that you try to write your function in a single line.

Here is an example of creating and calling a simple function:

CREATE OR REPLACE FUNCTION myfunction() RETURNS TEXT AS $$ BEGIN RETURN 'Hello, world!'; END; $$ LANGUAGE plpgsql;

SELECT myfunction();

Please let us know if you have any other questions.

Thank you for using SQLBackupAndFTP.