How to use the super type as a JSON-containing argument to a procedure and use the JSON elements in a FROM clause of a SELECT

0

Hello, I need to pass a JSON argument in a procedure to use it in a FROM clause of a SELECT.

So far I try :

CREATE OR REPLACE PROCEDURE public.test_json(Tparam VARCHAR(256)) LANGUAGE plpgsql AS $$ DECLARE elem VARCHAR(256);

BEGIN

DROP TABLE IF EXISTS temp ;

CREATE TABLE temp (jsonfield super);

INSERT INTO temp VALUES (JSON_PARSE(Tparam));

SELECT jsonfield."accountIds"[0] INTO elem FROM temp ;

SELECT myfield FROM mytable WHERE myfield=elem ;

END; $$

But I would prefer to do it directly : « SELECT jsonfield."accountIds"[0] INTO elem FROM Tparam ; »

If you a any idea I will be very happy.

Pascal J

질문됨 2년 전218회 조회
1개 답변
0

Without solution we give up stored procedures and choose to use embedded sql in our code.

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠