diff artifact-database/src/main/resources/sql/org-h2-driver.properties @ 274:92166f7c3842

#50 Added code on database level to recognize the oldest collection item in a collection (-> master artifact). artifacts/trunk@2071 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 07 Jun 2011 17:09:25 +0000
parents 22a90706d32d
children e92d5944fe4b
line wrap: on
line diff
--- a/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Jun 07 16:27:47 2011 +0000
+++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties	Tue Jun 07 17:09:25 2011 +0000
@@ -51,8 +51,8 @@
 collection.items.id.nextval=SELECT NEXTVAL('COLLECTION_ITEMS_ID_SEQ')
 
 collection.items.insert=INSERT INTO collection_items \
-    (id, collection_id, artifact_id, attribute) \
-    VALUES (?, ?, ?, ?)
+    (id, collection_id, artifact_id, attribute, creation) \
+    VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)
 
 collection.item.get.attribute= \
     SELECT ci.attribute FROM collection_items ci \
@@ -85,7 +85,8 @@
 collection.items.list.gid= \
     SELECT a.gid, ci.attribute FROM collection_items ci \
     INNER JOIN artifacts a ON ci.artifact_id = a.id \
-    WHERE ci.collection_id IN (SELECT id FROM collections WHERE gid = ?)
+    WHERE ci.collection_id IN (SELECT id FROM collections WHERE gid = ?) \
+    ORDER BY ci.creation
 
 # COLLECTIONS
 

http://dive4elements.wald.intevation.org