aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql9
1 files changed, 4 insertions, 5 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 76175b18..f9f04e55 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1706,12 +1706,11 @@ RETURN id;
End;
$$ LANGUAGE plpgsql;
-CREATE OR REPLACE FUNCTION public.id_translate(VARIADIC id1 character varying[])
-RETURNS TABLE(id2 text) AS $$
+CREATE OR REPLACE FUNCTION id_translate(VARIADIC id1 varchar(9)[])
+RETURNS TABLE(id2 varchar(12)) AS $$
BEGIN
- RETURN QUERY SELECT b.figi FROM
- (SELECT unnest(id1) AS cusip, generate_subscripts(id1, 1) AS id) a
- LEFT JOIN (SELECT DISTINCT ON (cusip) * FROM securities) as b
+ RETURN QUERY SELECT figi FROM securities
+ JOIN unnest(id1) WITH ORDINALITY AS t(cusip, id)
USING (cusip) ORDER BY id;
END;
$$ LANGUAGE plpgsql;