create or replace procedure "public"."extract"("arg" json)
language plpgsql
as $$
declare
"hell" json := "arg"->>'global', "arg"->> 'transactional';
begin
raise notice 'test:%', "hell"->>'packetType';
raise notice 'test1:%', "hell"->>'A';
-- freeze the input
end
$$;
call "public"."extract"('{"global":{"packetType":"1"},"transactional":{"A":{"electrical":"23"}}}');
ERROR I AM GETTING - SQL Error [42601]: ERROR: query "SELECT "arg"->>'global', "arg"->> 'transactional'" returned 2 columns Where: PL/pgSQL function "extract"(json) line 4 during statement block local variable initialization
PLEASE can you help me where can i fix the issue, i am unable to understand.
CodePudding user response:
The variable "hell" sounds like useless here, try something like this :
create or replace procedure "public"."extract"(arg json)
language plpgsql as $$
begin
raise notice 'test:%', arg->'global'->>'packetType';
raise notice 'test1:%', arg-> 'transactional'->>'A';
-- freeze the input
end ;
$$;
