Ex11 Clearup database script

This forum is for discussing the development of Rel examples and sample applications.
Post Reply
Chris Walton
Posts: 76
Joined: Sat Aug 18, 2012 2:13 pm

Ex11 Clearup database script

Post by Chris Walton » Fri Nov 29, 2013 12:43 am

Code: Select all

// Database Cleanup Script

WRITELN "/*** Clears the database of all user defined elements. ***/";
WRITELN;

BEGIN TRANSACTION;

FOR 
  UNION { 
    EXTEND sys.Catalog { Name, Owner, CreationSequence } WHERE Owner <> "Rel" : {
      Deletion := "DROP VAR " || Name || ";" }  { CreationSequence, Deletion },
    EXTEND sys.Types { Name, Owner, CreationSequence } WHERE Owner <> "Rel" : { 
      Deletion := "DROP TYPE " || Name || ";" } { CreationSequence, Deletion },
    EXTEND sys.Constraints { Name, Owner, CreationSequence } WHERE Owner <> "Rel" : { 
      Deletion := "DROP CONSTRAINT " || Name || ";" } { CreationSequence, Deletion },
    EXTEND ( ( sys.Operators UNGROUP ( Implementations ) ) WHERE CreatedByType = "" ) {
      Name, Owner, CreationSequence, Signature } WHERE Owner <> "Rel" : { 
        Deletion := "DROP OPERATOR " || Name || SUBSTRING ( 
          Signature, INDEX_OF ( Signature, "(" ), 
          INDEX_OF ( Signature, ")" ) + 1 ) || ";" } { CreationSequence, Deletion } }
  ORDER ( DESC CreationSequence );
  EXECUTE Deletion;
END FOR;

COMMIT;

WRITELN "End of Script.";

Post Reply