Ignore:
Timestamp:
08/05/08 11:20:55 (12 years ago)
Author:
cbyrom
Message:

Add new stored proc to cleanly delete an ingested document and all
its associated data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/branches/ingestAutomation-upgrade/database/ingest_procedures.sql

    r3860 r3863  
    3838                RETURN db_id; 
    3939     END; 
     40$$ LANGUAGE 'plpgsql'; 
     41 
     42 
     43DROP FUNCTION delete_document(original_document_id_in int) CASCADE; 
     44CREATE FUNCTION delete_document(original_document_id_in int) RETURNS VOID AS  
     45$$ 
     46        DECLARE 
     47                db_id integer; 
     48    BEGIN 
     49        -- This deletes a document from the DB 
     50        DELETE FROM TRANSFORMED_DOCUMENT WHERE original_document_id = original_document_id_in; 
     51                DELETE FROM SPATIAL_TEMPORAL_DATA WHERE original_document_id = original_document_id_in; 
     52        DELETE FROM ORIGINAL_DOCUMENT WHERE original_document_id = original_document_id_in; 
     53        END; 
    4054$$ LANGUAGE 'plpgsql'; 
    4155 
     
    116130 
    117131                -- Now create row in link table 
    118                 INSERT INTO SPATIAL_TEMPORAL_DATA (spatial_temporal_data_id, original_record_id, 
     132                INSERT INTO SPATIAL_TEMPORAL_DATA (spatial_temporal_data_id, original_document_id, 
    119133                        spatial_data_id, temporal_data_id, create_date) VALUES 
    120134                        (DEFAULT, original_document_id_in, spatial_db_id, temporal_db_id, current_timestamp); 
Note: See TracChangeset for help on using the changeset viewer.