source: TI01-discovery/branches/ingestAutomation-upgrade/database/ingest_procedures.sql @ 3834

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/branches/ingestAutomation-upgrade/database/ingest_procedures.sql@3834
Revision 3834, 534 bytes checked in by cbyrom, 12 years ago (diff)

Changes to data model:
i) Simplify creation script - to take input parameters and reuse these in a env variable
ii) Create history table direct from the main table
iii) Create procedure to do the backup to the history table
iv) Add trigger to call the backup procedure
v) Tidy up of spatio + temporal tables + additional docs.

Line 
1/*
2 * Procedures used by the DB code as part of the ingest process
3 *
4 * C Byrom Apr 08
5 *
6 */
7DROP FUNCTION add_document_to_history() CASCADE;
8CREATE FUNCTION add_document_to_history() RETURNS OPAQUE AS '
9    BEGIN
10       -- This inserts the currently stored information
11        -- into the original_document_history table
12        INSERT INTO original_document_history
13                SELECT * FROM original_document WHERE original_document_id=NEW.original_document_id;
14
15                RETURN NEW;
16     END;
17' LANGUAGE 'plpgsql';
Note: See TracBrowser for help on using the repository browser.