Rem
Rem $Header: exp_alg.sql 25-jun-2003.16:50:56 gtang Exp $
Rem
Rem exp_alg.sql
Rem
Rem Copyright (c) 2003, Oracle Corporation.  All rights reserved.  
Rem
Rem    NAME
Rem      exp_alg.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 algorithm
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 algorithm 
Rem       has been created in the user schema
Rem
Rem    MODIFIED   (MM/DD/YY) 
Rem    gtang       06/25/03 - gtang_txn107754
Rem    gtang       06/24/03 - Creation
Rem

DECLARE
  job_name   VARCHAR2(30) := 'nbmodels';
  filter_str VARCHAR2(100);
  v_err_msg  VARCHAR2(200);
BEGIN 
  filter_str := 'ALGORITHM_NAME=''NAIVE_BAYES''';
  dmsys.dbms_data_mining.export_model(model_filter=>filter_str,
                                      filename=>job_name,
                                      directory=>'DM_DUMP',
                                      filesize=>'30M',
                                      operation=>'EXPORT',
                                      jobname=>job_name);
  
  EXCEPTION
    WHEN OTHERS THEN 
      v_err_msg := SUBSTR(SQLERRM, 1, 200);
      dbms_output.put_line(job_name||' failed! Error='||v_err_msg);

END;
/