Rem
Rem $Header: exp_cls.sql 25-jun-2003.16:50:58 gtang Exp $
Rem
Rem exp_cls.sql
Rem
Rem Copyright (c) 2003, Oracle Corporation.  All rights reserved.  
Rem
Rem    NAME
Rem      exp_cls.sql - Data Mining model export demo
Rem
Rem    DESCRIPTION
Rem      This script demonstrates the use of export_model(),
Rem      to export all models of a specific function
Rem
Rem    NOTES
Rem     Prerequisits:
Rem     - directory object 'DM_DUMP' is already creaed
Rem     - the user has WRITE priviledge on 'DM_DUMP'
Rem     - at least 1 model of the specific function 
Rem       has been created in the user schema
Rem
Rem    MODIFIED   (MM/DD/YY) 
Rem    gtang       06/25/03 - gtang_txn107754
Rem    gtang       06/25/03 - 
Rem    gtang       06/24/03 - Creation
Rem

DECLARE
  job_name   VARCHAR2(30) := 'clsmodels';
  filter_str  VARCHAR2(200);
  file_name   VARCHAR2(32);
  v_err_msg   VARCHAR2(200);
BEGIN 
  file_name := job_name;
  filter_str := 'FUNCTION_NAME=''CLASSIFICATION''';
  dmsys.dbms_data_mining.export_model(model_filter=>filter_str,
                                      filename=>file_name,
                                      directory=>'DM_DUMP');
  dbms_output.put_line('dbms_data_mining.export_model: job '||job_name||' completed successfully!');
  
  EXCEPTION
    WHEN OTHERS THEN 
      v_err_msg := SUBSTR(SQLERRM, 1, 200);
      dbms_output.put_line('EXPORT TEST failed! Error='||v_err_msg);

END;
/