Ticket #1924: Trac_1924.Dataviews.sql

File Trac_1924.Dataviews.sql, 3.7 KB (added by Benjamin Haag, 7 years ago)

DataView SQL

Line 
1-- **********************************************************************************
2-- get_taxonomy_ref_cwr_trait
3-- **********************************************************************************
4SELECT
5 ct.taxonomy_ref_cwr_trait_id,
6 ct.trait_code,
7 ct.title,
8 ct.description,
9 ct.created_date,
10 ct.created_by,
11 ct.modified_date,
12 ct.modified_by,
13 ct.owned_date,
14 ct.owned_by
15FROM
16 taxonomy_ref_cwr_trait ct
17INNER JOIN (
18 SELECT
19 taxonomy_ref_cwr_trait_id
20 FROM
21 taxonomy_ref_cwr_trait
22 WHERE
23 taxonomy_ref_cwr_trait_id IN (:taxonomyrefcwrtraitid)) list
24 ON
25 list.taxonomy_ref_cwr_trait_id = ct.taxonomy_ref_cwr_trait_id
26
27-- **********************************************************************************
28-- get_taxonomy_ref_cwr_breeding_type
29-- **********************************************************************************
30SELECT
31 bt.taxonomy_ref_cwr_breeding_type_id,
32 bt.breeding_type_code,
33 bt.title,
34 bt.description,
35 bt.created_date,
36 bt.created_by,
37 bt.modified_date,
38 bt.modified_by,
39 bt.owned_date,
40 bt.owned_by
41FROM
42 taxonomy_ref_cwr_breeding_type bt
43INNER JOIN (
44 SELECT
45 taxonomy_ref_cwr_breeding_type_id
46 FROM
47 taxonomy_ref_cwr_breeding_type
48 WHERE
49 taxonomy_ref_cwr_breeding_type_id IN (:taxonomyrefcwrbreedingtypeid)) list
50 ON
51 list.taxonomy_ref_cwr_breeding_type_id = bt.taxonomy_ref_cwr_breeding_type_id
52
53
54-- **********************************************************************************
55-- get_taxonomy_cwr_trait_map
56-- **********************************************************************************
57SELECT
58 tc.crop_name,
59 ts.name,
60 bt.title,
61 t.title,
62 t.trait_code,
63 tm.taxonomy_cwr_trait_map_id,
64 tm.taxonomy_crop_id,
65 tm.taxonomy_species_id,
66 tm.taxonomy_ref_cwr_breeding_type_id,
67 tm.taxonomy_ref_cwr_trait_id,
68 tm.breeding_usage_note,
69 tm.ontology_trait_identifier,
70 tm.citation_id,
71 tm.note,
72 tm.created_date,
73 tm.created_by,
74 tm.modified_date,
75 tm.modified_by,
76 tm.owned_date,
77 tm.owned_by
78FROM
79 taxonomy_cwr_trait_map tm
80JOIN
81 taxonomy_crop tc
82ON
83 tm.taxonomy_crop_id = tc.taxonomy_crop_id
84JOIN
85 taxonomy_species ts
86ON
87 tm.taxonomy_species_id = ts.taxonomy_species_id
88JOIN
89 taxonomy_ref_cwr_breeding_type bt
90ON
91 tm.taxonomy_ref_cwr_breeding_type_id = bt.taxonomy_ref_cwr_breeding_type_id
92JOIN
93 taxonomy_ref_cwr_trait t
94ON
95 tm.taxonomy_ref_cwr_trait_id = t.taxonomy_ref_cwr_trait_id
96INNER JOIN (
97 SELECT
98 taxonomy_cwr_trait_map_id
99 FROM
100 taxonomy_cwr_trait_map
101 WHERE
102 taxonomy_cwr_trait_map_id IN (5,6,7,8,9)) list
103 ON
104 list.taxonomy_cwr_trait_map_id = tm.taxonomy_cwr_trait_map_id
105
106-- **********************************************************************************
107-- cwr_breeding_type_lookup
108-- **********************************************************************************
109SELECT
110 b.taxonomy_ref_cwr_breeding_type_id AS value_member,
111 b.title AS display_member
112FROM
113 taxonomy_ref_cwr_breeding_type b
114WHERE
115 ((b.created_date > COALESCE(:createddate, '1753-01-01'))
116 OR (b.modified_date > COALESCE(:modifieddate, '1753-01-01'))
117 OR (b.method_id IN (:valuemember))
118 OR (b.method_id BETWEEN :startpkey AND :stoppkey)
119 )
120
121 -- **********************************************************************************
122-- cwr_trait_lookup
123-- **********************************************************************************
124SELECT
125 t.taxonomy_ref_cwr_trait_id AS value_member,
126 t.title AS display_member
127FROM
128 taxonomy_ref_cwr_trait t
129WHERE
130 ((t.created_date > COALESCE(:createddate, '1753-01-01'))
131 OR (t.modified_date > COALESCE(:modifieddate, '1753-01-01'))
132 OR (t.method_id IN (:valuemember))
133 OR (t.method_id BETWEEN :startpkey AND :stoppkey)
134 )