SET client_min_messages = notice;
DO $$
DECLARE
__ID_PERSONA INTEGER DEFAULT 1;
__campos JSONB;
_msj TEXT;
BEGIN
FOR __campos IN SELECT JSONB_ARRAY_ELEMENTS('[{"id":1 }, {"id":2}]'::JSONB)
LOOP
IF (__campos->>'id') = '1' THEN
CONTINUE;
END IF;
RAISE NOTICE ' campos %' , __campos->>'id';
END LOOP;
EXCEPTION
WHEN others THEN
GET STACKED DIAGNOSTICS _msj = PG_EXCEPTION_CONTEXT;
raise notice 'ERROR : % %', SQLERRM, SQLSTATE;
END
$$
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.