source: branches/3.18-stable/config/dist/mysql-queries.xml @ 7938

Last change on this file since 7938 was 7290, checked in by Nicklas Nordborg, 5 years ago

Merged pre-3.10 release changes back to trunk.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Date Id
File size: 6.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: mysql-queries.xml 7290 2017-01-31 12:13:44Z nicklas $
5
6  Copyright (C) 2006 Nicklas Nordborg
7
8  This file is part of BASE - BioArray Software Environment.
9  Available at http://base.thep.lu.se/
10
11  BASE is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License
13  as published by the Free Software Foundation; either version 3
14  of the License, or (at your option) any later version.
15
16  BASE is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  GNU General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with BASE. If not, see <http://www.gnu.org/licenses/>.
23-->
24<!--
25  This file contains HQL and SQL queries that have been modified
26  specifically for the MySQL database and overrides the queries
27  found in the common-queries.xml file.
28-->
29<predefined-queries>
30  <query id="DROP_NOT_NULL_CONSTRAINT" type="SQL">
31    <sql>
32      ALTER TABLE [{1}] MODIFY [{2}] {3} NULL
33    </sql>
34    <description>
35      An SQL query that drops a NOT NULL contraint from column (2) with data type (3)
36      in a table (1).
37    </description>
38  </query>
39
40  <query id="AB_INSERT_INTO_PARAMETERVALUES" type="SQL">
41    <sql>
42      INSERT INTO [ParameterValues] ([discriminator], [version])
43      VALUES (?, 0)
44    </sql>
45    <description>
46      SQL query for inserting rows into the ParameterValues table.
47      The primary key (id) must be auto-generated.
48      Parameters: discriminator
49    </description>
50  </query>
51
52  <query id="AB_INSERT_INTO_ANNOTATIONS" type="SQL">
53    <sql>
54      INSERT INTO [Annotations] ([version], [annotationset_id], [annotationtype_id], [unit_id], [value_id], [last_update], [source], [project_id], [override_id])
55      VALUES (0, ?, ?, ?, ?, ?, 0, ?, ?)
56    </sql>
57    <description>
58      SQL query for inserting rows into the Annotations table.
59      The primary key (id) must be auto-generated.
60      Parameters: annotationset_id, annotationtype_id, unit_id, value_id, last_updated, project_id, override_id
61    </description>
62  </query>
63 
64  <query id="AB_INSERT_INTO_ANNOTATIONSETS" type="SQL">
65    <sql>
66      INSERT INTO [AnnotationSets] ([version], [item_type], [item_id])
67      VALUES (0, {1}, ?)
68    </sql>
69    <description>
70      SQL query for inserting rows into the AnnotationSets table.
71      The primary key (id) must be auto-generated.
72      Parameters: item_id
73    </description>
74  </query>
75 
76  <query id="DBLOG_INSERT_INTO_CHANGEHISTORYDETAILS" type="SQL">
77    <sql>
78      INSERT INTO [ChangeHistoryDetails]
79        ([version], [history_id], [change_type], [item_id], [item_type], [change_info], [old_value], [new_value])
80      VALUES (0, ?, ?, ?, ?, ?, ?, ?)
81    </sql>
82    <description>
83      SQL query for inserting rows into the ChangeHistoryDetails table.
84      The primary key (id) must be auto-generated.
85      Parameters: history_id, change_type, item_id, item_type, change_info, old_value, new_value
86    </description>
87  </query>
88
89  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION" type="SQL">
90    <sql>
91      UPDATE [Annotations]
92      SET [override_id] = COALESCE(
93        (SELECT [tmp].[id] FROM (
94          SELECT [id] FROM [Annotations]
95          WHERE [annotationset_id] = :annotationSetId
96          AND [annotationtype_id] = :annotationTypeId
97          AND [source] = 0 AND [project_id] = 0
98        ) [tmp] )
99        , 0)
100      WHERE id = :annotationId
101    </sql>
102    <description>
103      Updates the "override_id" column on a newly created project-specific
104      (PRIMARY) annotation to point to the existing default annotation id
105      or 0 if no default annotation exists. To make this query work in MySQL
106      we need a double inner subselect to force a temporary table for the
107      single value we are after.
108    </description>
109  </query>
110 
111  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF_INHERITED" type="HQL">
112    <sql>
113      UPDATE [Annotations]
114      SET [override_id] = :annotationId
115      WHERE [annotationset_id] = :annotationSetId
116      AND [inherited_id] IN (
117        SELECT [tmp].[id] FROM (
118          SELECT [id] FROM [Annotations]
119          WHERE [annotationset_id] = :parentSetId
120          AND [override_id] = :parentId
121        ) [tmp]
122      )
123    </sql>
124    <description>
125      Updates the "override_id" column on project-specific annotations
126      to point to a newly created default annotation (INHERITED and
127      CLONED annotations). The subquery will find project-specific annotation
128      on the parent annotation set that is overriding the inherited annotation.
129     
130      To make this query work in MySQL we need a double inner subselect
131      to force a temporary table for the values we are after.
132    </description>
133  </query>
134 
135  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION_INHERITED" type="SQL">
136    <sql>
137      UPDATE [Annotations]
138      SET [override_id] = COALESCE(
139        (SELECT [tmp].[id] FROM (
140          SELECT [id] FROM [Annotations]
141          WHERE [annotationset_id] = :annotationSetId
142          AND [inherited_id] = :parentOverrideId
143          AND [source] &lt;&gt; 0
144          AND [project_id] = 0
145        ) [tmp])
146        , 0)
147      WHERE id = :annotationId
148    </sql>
149    <description>
150      Updates the "override_id" column on a newly created project-specific
151      (CLONED or INHERITED) annotation to point to the existing default
152      annotation id or 0 if no default annotation exists.
153     
154      To make this query work in MySQL we need a double inner subselect
155      to force a temporary table for the values we are after.
156    </description>
157  </query>
158
159  <query id="PS_RESET_OVERRIDE_ON_PROJECT_ANNOTATIONS" type="HQL">
160    <sql>
161      UPDATE [Annotations] 
162      SET [override_id] = 0
163      WHERE [override_id] IN (:deletedAnnotations)
164      OR [inherited_id] IN (
165        SELECT [tmp].[id] FROM (
166          SELECT [id] FROM [Annotations]
167          WHERE [override_id] IN (:deletedPrimaryAnnotations)
168        ) [tmp]
169      )
170    </sql>
171    <description>
172      Reset the "override_id" column on project-specific annotations
173      that points to a default annotation that has been removed.
174
175      To make this query work in MySQL we need a double inner subselect
176      to force a temporary table for the values we are after.
177    </description>
178  </query>
179 
180</predefined-queries>
Note: See TracBrowser for help on using the repository browser.