Revision 4537
Added by Aaron Marcuse-Kubitza over 12 years ago
inputs/VegBank/vegbank.~.utils.sql | ||
---|---|---|
30 | 30 |
LANGUAGE plpgsql STABLE STRICT |
31 | 31 |
COST 100 |
32 | 32 |
ROWS 10; |
33 |
|
|
34 |
-- Function: "VegBank".plantconcept_plantnames(integer) |
|
35 |
|
|
36 |
-- DROP FUNCTION "VegBank".plantconcept_plantnames(integer); |
|
37 |
|
|
38 |
CREATE OR REPLACE FUNCTION "VegBank".plantconcept_plantnames(IN plantconcept_id_ integer, OUT "Kingdom" text, OUT "Subkingdom" text, OUT "Superdivision" text, OUT "Division" text, OUT "Subdivision" text, OUT "Class" text, OUT "Subclass" text, OUT "Order" text, OUT "Family" text, OUT "Genus" text, OUT "Species" text, OUT "Subspecies" text, OUT "Variety" text, OUT "Forma" text) |
|
39 |
RETURNS record AS |
|
40 |
$BODY$ |
|
41 |
BEGIN |
|
42 |
-- Get plantconcept ancestors |
|
43 |
CREATE TEMP TABLE level_plantname AS |
|
44 |
SELECT plantlevel, plantname.plantname |
|
45 |
FROM "VegBank".plantconcept_ancestors(plantconcept_id_) |
|
46 |
JOIN "VegBank".plantconcept USING (plantconcept_id) |
|
47 |
JOIN "VegBank".plantname USING (plantname_id) |
|
48 |
; |
|
49 |
|
|
50 |
-- Extract name for each level |
|
51 |
"Kingdom" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Kingdom'); |
|
52 |
"Subkingdom" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Subkingdom'); |
|
53 |
"Superdivision" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Superdivision'); |
|
54 |
"Division" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Division'); |
|
55 |
"Subdivision" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Subdivision'); |
|
56 |
"Class" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Class'); |
|
57 |
"Subclass" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Subclass'); |
|
58 |
"Order" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Order'); |
|
59 |
"Family" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Family'); |
|
60 |
"Genus" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Genus'); |
|
61 |
"Species" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Species'); |
|
62 |
"Subspecies" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Subspecies'); |
|
63 |
"Variety" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Variety'); |
|
64 |
"Forma" := (SELECT plantname FROM level_plantname WHERE plantlevel = 'Forma'); |
|
65 |
|
|
66 |
-- Clean up |
|
67 |
DROP TABLE level_plantname; |
|
68 |
END; |
|
69 |
$BODY$ |
|
70 |
LANGUAGE plpgsql VOLATILE STRICT |
|
71 |
COST 100; |
Also available in: Unified diff
inputs/VegBank/vegbank.~.utils.sql: Added plantconcept_plantnames()