tww
.tww_app
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
vw_file_insert()
Parameters
Name
Type
Mode
IN
Definition
BEGIN NEW._url = replace(NEW._url, '\', '/'); INSERT INTO tww_od.file( classname, identifier, kind, object, path_relative, fk_dataowner, fk_provider, fk_data_media, remark) SELECT NEW.classname, NEW.identifier, NEW.kind, NEW.object, SUBSTRING(NEW._url, LENGTH("path")+1, LENGTH(NEW._url)), -- path_relative, NEW.dataowner, -- fk_dataowner, NEW.provider, -- fk_provider, obj_id, -- fk_data_media NEW.remark FROM tww_od.data_media WHERE "path" = SUBSTRING(NEW._url FROM 1 FOR LENGTH("path")) ORDER BY LENGTH("path") DESC LIMIT 1; -- FOUND is a special variable which is always FALSE at the beginning of a PL/pgsql function and will be set by -- e.g. INSERT to TRUE if at least one row is affected. IF NOT FOUND THEN RAISE WARNING 'Could not insert. File not in repository set in od_data_media!'; END IF; RETURN NEW; END;