スクリプトにおける SELECT コマンドの使用

IBM Storage Protect スクリプトは、データベースにオブジェクトとして保管される 1 つ以上のコマンドです。 スクリプトは、1 つ以上の SELECT コマンドを入れて定義することができます。

このタスクについて

スクリプトは、管理可能クライアント、またはサーバー・コンソールから実行できます。 また、スクリプトは、自動的に実行するために、管理コマンド・スケジュールの中に入れることもできます。 詳細については、「サーバースクリプト」 を参照してください。

IBM Storage Protect には、いくつかのサンプル・スクリプトを含むファイルが付属しています。 ファイル scripts.smp は、サーバー・ディレクトリー内にあります。 スクリプトを作成してオブジェクトとしてサーバーのデータベースに保管するには、インストール中に DSMSERV RUNFILE コマンドを発行します。
> dsmserv runfile scripts.smp
スクリプトは、管理コマンド・ライン・クライアントからマクロとして 実行することもできます。
macro scripts.smp

サンプル・スクリプト・ファイルには、コマンドが入っています。 これらのコマンドにより、定義するものと同じ名前のスクリプトがあれば、まずそれを削除してから、そのスクリプトを定義します。 ほとんどのサンプルは SELECT コマンドを作成しますが、ストレージ・プールをバックアップするものなどもあります。 サンプル・スクリプト・ファイルをコピーし、それを変更することによって、自分のスクリプトを作成することもできます。

次にサンプル・スクリプト・ファイルからの例を示します。
def script q_inactive_days '/* --------------------------------------------*/'
upd script q_inactive_days '/* Script Name:  Q_INACTIVE                    */'
upd script q_inactive_days '/* Description: Display nodes that have not    */'
upd script q_inactive_days '/*    accessed the backup server for a         */'
upd script q_inactive_days '/*    specified number of days                 */'
upd script q_inactive_days '/* Parameter 1: days                           */'
upd script q_inactive_days '/* Example:     run q_inactive_days 5          */'
upd script q_inactive_days '/* --------------------------------------------*/'
upd script q_inactive_days "select node_name,lastacc_time from nodes where -" 
upd script q_inactive_days " cast((current_timestamp-lastacc_time)days as -"  
upd script q_inactive_days " decimal) >= $1 "
/* Display messages in the activity log of severity X or Y                */
 
def script q_msg_sev desc='Show msgs in the activity log of severity X or Y'
upd script q_msg_sev '/* ------------------------------------------------*/'
upd script q_msg_sev '/* Script Name:  Q_MSG_SEV                         */'
upd script q_msg_sev '/* Description: Display messages in the            */'
upd script q_msg_sev '/*              activity log that have either      */'
upd script q_msg_sev '/*              of two specified severities.       */'
upd script q_msg_sev '/* Parameter 1: severity 1                         */'
upd script q_msg_sev '/* Parameter 2: severity 2                         */'
upd script q_msg_sev '/*  where severity is I, W, E, S, or D             */'
upd script q_msg_sev '/* Example:  run q_msg_sev S E                     */'
upd script q_msg_sev '/* ------------------------------------------------*/'
upd script q_msg_sev "select date_time,msgno,message from actlog -"
upd script q_msg_sev "  where severity=upper('$1') or severity=upper('$2')"