From d5c82371fcc0e58f01b3457e71d7fff99a709eb4 Mon Sep 17 00:00:00 2001
From: Luca Ferrari <fluca1978@gmail.com>
Date: Mon, 15 Jul 2024 12:24:13 +0200
Subject: PWC 278

Task 1 Raku done
Task 2 Raku done

Task 1 PL/perl done
Task 2 PL/Perl done

Task 1 PL/PgSQL done
Task 2 PL/PgSQL done

Task 1 PL/Java done
Task 2 PL/Java done

Task 1 Python done
Task 2 Python done
---
 challenge-278/luca-ferrari/plpgsql/ch-1.sql | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 challenge-278/luca-ferrari/plpgsql/ch-1.sql

(limited to 'challenge-278/luca-ferrari/plpgsql/ch-1.sql')

diff --git a/challenge-278/luca-ferrari/plpgsql/ch-1.sql b/challenge-278/luca-ferrari/plpgsql/ch-1.sql
new file mode 100644
index 0000000000..dfbc14b996
--- /dev/null
+++ b/challenge-278/luca-ferrari/plpgsql/ch-1.sql
@@ -0,0 +1,24 @@
+--
+-- Perl Weekly Challenge 278
+-- Task 1
+-- See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-278>
+--
+
+CREATE SCHEMA IF NOT EXISTS pwc278;
+
+CREATE OR REPLACE FUNCTION
+pwc278.task1_plpgsql( words text[] )
+RETURNS SETOF text
+AS $CODE$
+
+   WITH numbered AS (
+      SELECT substring( v::text from '^[a-zA-Z]+' ) as word
+           , substring( v::text from '\d+$' )::int as index
+      FROM unnest( words ) v
+   )
+   SELECT word
+   FROM numbered
+   ORDER BY index
+   ;
+$CODE$
+LANGUAGE sql;
-- 
cgit 

