From 093553020c7cf39461a2be0e1c8851c983ba863b Mon Sep 17 00:00:00 2001
From: Luca Ferrari <fluca1978@gmail.com>
Date: Mon, 26 Feb 2024 09:28:02 +0100
Subject: PWC 258

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 Python done
Task 2 Python done

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

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

diff --git a/challenge-258/luca-ferrari/plpgsql/ch-1.sql b/challenge-258/luca-ferrari/plpgsql/ch-1.sql
new file mode 100644
index 0000000000..7e02f746b8
--- /dev/null
+++ b/challenge-258/luca-ferrari/plpgsql/ch-1.sql
@@ -0,0 +1,22 @@
+--
+-- Perl Weekly Challenge 258
+-- Task 1
+-- See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-258>
+--
+
+CREATE SCHEMA IF NOT EXISTS pwc258;
+
+CREATE OR REPLACE FUNCTION
+pwc258.task1_plpgsql( nums int[] )
+RETURNS int
+AS $CODE$
+   WITH q_nums AS (
+   	SELECT v, array_length( regexp_split_to_array( v::text, '' ), 1 ) as c
+	FROM unnest( nums ) v
+	)
+	SELECT count( * )
+	FROM q_nums
+	WHERE c % 2 = 0;
+
+$CODE$
+LANGUAGE sql;
-- 
cgit 

