I am getting a problem while running my function in postgres version 9.3.9 It given me a below error when i run this:
Caused by: org.postgresql.util.PSQLException: ERROR: function json_typeof(json) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Where: PL/pgSQL function myArray(character varying,json) line 9 at SQL statement
Here is my function:
CREATE OR REPLACE FUNCTION myArray(domain_name varchar, val json) RETURNS varchar LANGUAGE plpgsql STABLE AS $$
DECLARE
result varchar;
isarray BOOLEAN;
q cursor for
select json_agg(blogIn(null,b.value))
from json_array_elements_text(val) b;
BEGIN
SELECT json_typeof(val) = 'array' into isarray;
if not isarray THEN
return val;
end if;
open q;
fetch q into result;
close q;
if result is null then
return val;
end if;
return result;
END;
$$;
It is very strange that this function run without any problem in Postgres 9.5 version but on 9.3 it creating above error. Can someone tell me what actually type cast it require at "SELECT json_typeof(val) = 'array' into isarray;" ?
json_typeof()was introduced in Postgres 9.4, so obviously it is not available in 9.3. Additionally: Postgres 9.3 is no longer supported you should plan an upgrade as soon as possible anyway