Advertisement
joaofabioma

function letra

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