Copy cartodb lib/sql scripts from CDB_CartodbfyTable branch

This commit is contained in:
Sandro Santilli
2014-05-05 17:13:06 +02:00
parent 7a5ce833a4
commit 2f1fdf5a15
43 changed files with 1569 additions and 4 deletions

View File

@@ -0,0 +1,19 @@
-- Convert string to date
--
CREATE OR REPLACE FUNCTION CDB_StringToDate(input character varying)
RETURNS date AS $$
DECLARE output DATE DEFAULT NULL;
BEGIN
BEGIN
output := input::date;
EXCEPTION WHEN OTHERS THEN
BEGIN
SELECT to_timestamp(input::integer) INTO output;
EXCEPTION WHEN OTHERS THEN
RETURN NULL;
END;
END;
RETURN output;
END;
$$
LANGUAGE 'plpgsql' STABLE STRICT;