admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Quintiq file version 2.0
#parent: #root
StaticMethod DeleteDataset (
  String datasetName_i
)
{
  TextBody:
  [*
    // First see if the dataset is online.
    includeOffline := false;
    datasetKey     := LibDIF_IntegrationDataset::FindDatasetKey( datasetName_i, includeOffline );
    
    if( datasetKey <> Key::ZeroKey() )
    {
      // Capture the dataset to be able to get its StorageState. 
      DatasetController::Root( datasetKey )->( dataset )
      {
        // First unload the dataset.
        DatasetController::Unload( datasetKey );
    
        // Delete the dataset if necessary.
        // Should not be done for a MemoryOnly-dataset, because that is already automatically deleted after it has been unloaded.
        if( LibDIF_IntegrationDataset::GetStorageState( dataset ) <> DatasetState::MemoryOnly().AsString() )
        {
          DatasetController::Delete( datasetKey );
        }
      }
    }
    else
    {
      // See if the dataset is offline. 
      includeOffline := true;
      datasetKey     := LibDIF_IntegrationDataset::FindDatasetKey( datasetName_i, includeOffline );
    
      if( datasetKey <> Key::ZeroKey() )
      {
        // Delete the datsset.
        DatasetController::Delete( datasetKey );
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}