How to fix Execute format error?

From: Joe How <huijoehow(at)gmail(dot)com>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: How to fix Execute format error?
Date: 2021-02-05 11:22:55
Message-ID: CAPM0uuWuF-4O9fgDVG_RcmUrkPvUZmznXEc-UViakpuOY1R6mg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear all,

I have a query in Postgres like below:

EXECUTE FORMAT(
$$ SELECT * FROM %I.%I CROSS JOIN LATERAL json_to_record(%I::json)
AS rs(%s); $$,
'public',
'vehicles',
'column_a',
array_to_string(
(SELECT ARRAY(SELECT DISTINCT col FROM vehicles CROSS
JOIN LATERAL json_object_keys(column_a::json) AS t(col) ORDER BY
col)), ' text , '
) || ' text'
);

I got an error message when I run it in pgadmin:
ERROR: prepared statement "format" does not exist SQL state: 26000

Any advice on how to fix it? Thanks

--
Best Regards,
Joe

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2021-02-05 15:01:37 Re: How to fix Execute format error?
Previous Message Roberto Médola 2021-01-29 16:47:37 Re: Bring to dead tuples to alive