Check if a string is a function. And call this string with arguments. Update SQL files for better layout order
18 lines
395 B
PL/PgSQL
18 lines
395 B
PL/PgSQL
-- create random string with length X
|
|
|
|
CREATE FUNCTION random_string(randomLength int)
|
|
RETURNS text AS $$
|
|
SELECT array_to_string(
|
|
ARRAY(
|
|
SELECT substring(
|
|
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
|
|
trunc(random() * 62)::int + 1,
|
|
1
|
|
)
|
|
FROM generate_series(1, randomLength) AS gs(x)
|
|
),
|
|
''
|
|
)
|
|
$$ LANGUAGE SQL
|
|
RETURNS NULL ON NULL INPUT
|
|
VOLATILE; -- LEAKPROOF; |