Impares (Función anónima)

SET client_min_messages = notice; DO $$ DECLARE __ID_PERSONA INTEGER DEFAULT 1; __campos INTEGER; __numeros_imp INTEGER[]; _msj TEXT; BEGIN FOR __campos IN SELECT UNNEST(ARRAY[1,2,3,4,5,6,7]) LOOP IF __campos % 2 = 1 THEN __numeros_imp := __numeros_imp || ARRAY[__campos]; RAISE NOTICE ' __campos %' , __campos; END IF; END LOOP; RAISE NOTICE ' IMPARES => % ', __numeros_imp; 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.