# TGsq.cfg: Manages SQL*Plus Query Target Definitions # # $Id: TGsq.cfg,v 1.6 2015/08/28 07:34:56 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/RDA/TGsq.cfg,v 1.6 2015/08/28 07:34:56 RDA Exp $ # # Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. # # Change History # 20150828 MSC Add N_ATTEMPTS management. #------------------------------------------------------------------------------ # Module definition #------------------------------------------------------------------------------ dsc='Manages SQL*Plus Query Target Definitions' var=select_command exe=sdcl { "macro gen_title "{var ($tgt) = @arg " " var $ttl = concat('Using ',$tgt->get_first('T_USER','/')) " if $tgt->get_first('B_SYSDBA') " var $ttl = concat($ttl,' as SYSDBA') " if $tgt->get_first('T_ORACLE_SID') " var $ttl = concat($ttl,' at ',last) " else " var $ttl = concat($ttl,' locally') " return $ttl "} " "macro is_local "{if or(${I_DATABASE},\ " ${I_ORACLE_BASE},\ " ${I_ORACLE_HOME},\ " ${D_ORACLE_BASE},\ " ${D_ORACLE_HOME},\ " ${T_ORACLE_HOME},\ " ${RUN.CLASS.SQ.I_DATABASE},\ " ${RUN.CLASS.DB.I_ORACLE_BASE},\ " ${RUN.CLASS.DB.I_ORACLE_HOME},\ " ${RUN.CLASS.OB.D_ORACLE_BASE},\ " ${RUN.CLASS.OH.D_ORACLE_HOME},\ " ${RUN.CLASS.OH.T_ORACLE_HOME}) " return true " if match(${T_USER},'@') " return false " if match(${T_ORACLE_SID},':|^\(DESCRIPTION=\(.*\)\)') " return false " if !${CUR.B_NO_DIALOG} " return true " if compare('eq',${T_USER},'/') " return true " if ?${RUN.CLASS.OH.D_ORACLE_HOME} " return true " if ${B_MISSING_BASE} " return false " if ?${RUN.CLASS.OH.D_ORACLE_BASE} " return true " return false "} " "macro is_unique "{var ($cur,$ttl) = @arg " " loop $itm ($[COL]->get_items('SQ')) " {if and(compare('eq',$ttl,$itm->get_first('T_TITLE')),\ " compare('ne',$cur,$itm->get_path)) " return false " } " return true "} } #------------------------------------------------------------------------------ # Setting definitions #------------------------------------------------------------------------------ [select_command] typ=T dft=${W_ADMIN_COMMAND} dsc='Select the administration action' nam=- var=define:do_define:\ edit: do_edit:\ select:do_select #------------------------------------------------------------------------------ # Define a query target #------------------------------------------------------------------------------ [do_define] typ=B dft=${T_ADMIN_VALUE} nam=- var=true:W_CLASS,B_DEDICATED,T_USER,need_sysdba,T_ORACLE_SID,T_TITLE,\ N_ATTEMPTS,B_LOCAL exe=sdcl { "var $cnt = undef } [W_CLASS] typ=T def=${T_ADMIN_VALUE} dft='SQ' dsc='Target type' [B_DEDICATED] typ=B def=${T_ADMIN_VALUE} dft=${RUN.CLASS.SQ.B_DEDICATED} dsc='Is it a dedicated target?' opt=true [T_USER] typ=T def=${T_ADMIN_VALUE} dft=${RUN.CLASS.SQ.T_USER:'system'} dsc='User to connect to SQL*Plus' inp="Enter an Oracle User ID (user identifier only) to view DBA_ and V$ \ tables. If RDA will be run under the Oracle software owner's ID, then \ enter a '/' here, and select Y at the SYSDBA prompt to avoid being \ prompted for the database password at run time." [need_sysdba] typ=B def=${T_ADMIN_VALUE} dft=${RUN.CLASS.SQ.B_SYSDBA:check(${T_USER},'^\/',true,${B_SYSDBA})} dsc="Indicate that ${T_USER} will connect as SYSDBA" inp="Is '${T_USER}' a SYSDBA user (will connect as SYSDBA) (Y/N)?" nam=B_SYSDBA [T_ORACLE_SID] typ=T def=${T_ADMIN_VALUE} dft=${RUN.CLASS.SQ.T_ORACLE_SID:${ENV.ORACLE_SID}} dsc='Oracle SID' inp='Enter the Oracle SID to be analyzed' [T_TITLE] typ=T def=${T_ADMIN_VALUE} dft=${RUN.CLASS.SQ.T_TITLE:gen_title(${CUR.O_MODULE})} dsc='SQL*Plus Query target description' err='Duplicate description' inp='Enter the query target description' ref=is_unique(${CUR.K_MODULE},last) val=E [N_ATTEMPTS] typ=N def=${T_ADMIN_VALUE} dft=${RUN.CLASS.SQ.N_ATTEMPTS} dsc='Maximum number of SQL execution attempts' err='The number of attempts must be a positive integer' opt=true ref='I[0,[' val=F [B_LOCAL] typ=B def=${T_ADMIN_VALUE} dft=${RUN.CLASS.SQ.B_LOCAL:is_local()} dsc='Is a local connection required?' inp='Is a local connection required (Y/N)?' var=true:I_DATABASE [I_DATABASE] typ=I bef="Select a database target for '${T_ORACLE_SID}':" cls='DB' def=${T_ADMIN_VALUE} dft=(${RUN.CLASS.SQ.I_DATABASE},findItem('DB','T_ORACLE_SID',${T_ORACLE_SID})) inp='Specify the Oracle database' dsc='Oracle database target' exe=sdcl { "if ${RUN.CLASS.DB.T_ORACLE_SID/M} " var ${RUN.CLASS.DB.T_ORACLE_SID} = ${T_ORACLE_SID} } #------------------------------------------------------------------------------ # Edit a query target #------------------------------------------------------------------------------ [do_edit] typ=M add=('R|Return to the previous menu|-|-') aft='\040' bef='Edit a query target:' cas=false dft=(@{T_ADMIN_VALUE}) dsc='Edit a query target' err='Invalid entry' inp='Enter the item number or the action letter.' nam=-T_ADMIN_VALUE val=E var=-::do_define exe=sdcl { "# Get the target list "if !?$cnt "{keep $cnt,@itm,@rsp " var ($cnt,@itm,@rsp) = (0) " loop $itm ($[COL]->get_items('SQ')) " {var $pth = concat('COL/',$itm->get_path) " call push(@itm,incr($cnt),$itm->get_first('T_TITLE',$pth)) " call push(@rsp,$cnt,$pth) " } "} " "# Determine the menu items and responses "var ${AUX.itm} = [@itm] "var ${AUX.rsp} = [@rsp] } #------------------------------------------------------------------------------ # Select a query target #------------------------------------------------------------------------------ [do_select] typ=M aft='\040' alt=add_target,do_define,do_select ask=true cas=false dft=(@{T_ADMIN_VALUE}) dsc='Select a query' nam=-T_ADMIN_VALUE val=E var=+:add_target,do_define,do_select:\ -:do_edit,do_select:\ *:all_targets:\ .:no_targets exe=sdcl { "# Get the target list "if !?$cnt "{keep $cnt,@add,@all,@itm,@mnu,@rsp " " var ($cnt,@all,@itm,@mnu,@rsp) = (0) " if ${B_ADMIN_END} " {loop $itm ($[COL]->get_items('SQ')) " {next $itm->get_first('B_DEDICATED') " var $pth = concat('COL/',$itm->get_path) " call push(@itm,incr($cnt),$itm->get_first('T_TITLE',$pth)) " call push(@rsp,$cnt,$pth) " call push(@all,$pth) " call push(@mnu,$cnt) " } " } " else " {loop $itm ($[COL]->get_items('SQ')) " {var $pth = concat('COL/',$itm->get_path) " call push(@itm,incr($cnt),$itm->get_first('T_TITLE',$pth)) " call push(@rsp,$cnt,$pth) " next $itm->get_first('B_DEDICATED') " call push(@mnu,$cnt) " } " } "} " "# Determine the menu items and responses "var @add = ('D|Define a new query target|+|-') "if $cnt " call push(@add,'E|Edit a query target|-|-') "if ${B_ADMIN_END} "{if $cnt " call unshift(@add,'A|All query targets|*|-') " call push(@add,'N|No query targets|.|-') " var ${AUX.bef} = ${T_ADMIN_BEFORE:'Select a query target list:'} " var ${AUX.opt} = false " var ${AUX.pck} = true "} "else "{var ${AUX.bef} = ${T_ADMIN_BEFORE:'Select a query target:'} " var ${AUX.err} = 'Invalid entry' " var ${AUX.inp} = 'Enter the item number or the action letter.' " var ${AUX.opt} = cond($cnt,false,true) "} "var ${AUX.add} = [@add] "var ${AUX.itm} = [@itm] "var ${AUX.mnu} = [@mnu] "var ${AUX.rsp} = [@rsp] } [add_target] typ=T dft="COL/${NXT.SQ:${K_ADMIN_PARENT}}" dsc='Determine the identifier for a new target' nam=-T_ADMIN_VALUE [all_targets] typ=T dft=(@all) dsc='Select all targets' end='' nam=-T_ADMIN_VALUE [no_targets] typ=T dft=() dsc='Select no targets' end='' nam=-T_ADMIN_VALUE