Advertisement
joaofabioma

function letras

May 25th, 2022 (edited)
681
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- FUNCTION: public.letras()
  2.  
  3. -- DROP FUNCTION IF EXISTS public.letras();
  4.  
  5. CREATE OR REPLACE FUNCTION public.letras(
  6.     )
  7.     RETURNS TABLE(codigo integer)
  8.     LANGUAGE 'plpgsql'
  9.     COST 50
  10.     VOLATILE LEAKPROOF PARALLEL UNSAFE
  11.     ROWS 1000
  12.  
  13. AS $BODY$
  14. BEGIN
  15.     RETURN QUERY
  16.     (
  17.         WITH
  18.             minusculas AS
  19.             (
  20.                 SELECT cod FROM generate_series(97, 122, 1) cod ORDER BY random() * 25
  21.             ),
  22.             maiusculas AS
  23.             (
  24.                 SELECT cod FROM generate_series(65,90, 1) cod ORDER BY random() * 25
  25.             )
  26.         SELECT cod FROM maiusculas UNION ALL SELECT cod FROM minusculas
  27.     );
  28. END;
  29. $BODY$;
  30.  
  31. ALTER FUNCTION public.letras()
  32.     OWNER TO postgres;
  33.  
Advertisement
RAW Paste Data Copied
Advertisement