]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
d48e8b82702eb44c42e8c87751b15811bf2a2a9d
[tmp/jakarta-migration.git] /
1 CREATE OR REPLACE FUNCTION computecurrentlocation(character varying) RETURNS character varying
2     AS 'select m.currentlocation as computedcurrentlocation
3 from movements_common m,
4 hierarchy h1, 
5 relations_common r, 
6 hierarchy h2,
7 collectionobjects_common c,
8 misc misc
9 where m.id=h1.id
10 and r.subjectcsid=h1.name
11 and r.subjectdocumenttype=''Movement''
12 and r.objectdocumenttype=''CollectionObject''
13 and r.objectcsid=h2.name 
14 and h2.id=c.id
15 and misc.id = c.id
16 and misc.lifecyclestate <> ''deleted''
17 and m.currentlocation is not null
18 and m.locationdate is not null
19 and h2.name=$1
20 order by m.locationdate desc,row_number() over(order by locationdate)
21 limit 1'
22 LANGUAGE SQL
23     IMMUTABLE
24     RETURNS NULL ON NULL INPUT;