<?xml version="1.0" encoding="UTF-8" ?>
<!--
  ~ Copyright (c) DbVis Software AB. All Rights Reserved.
  -->

<!DOCTYPE DatabaseProfile SYSTEM "dbvis-defs.dtd">

<DatabaseProfile
        desc="Profile for DB2 LUW"
        minver="9.5"
        extends="generic">

   <!-- =================================================================== -->
   <!-- Definition of the commands -->
   <!-- =================================================================== -->

   <Commands extends="true">

      <!--
        The "getTableNamesFor" command is used by Database getTableNamesFor().
        It must return table names for the catalog and schema named by
        the ${table_catalog} and ${table_catalog} variables in the first
        column.
      -->
      <Command id="db2.getTableNamesFor">
        <SQL>
          <![CDATA[
SELECT tabname FROM  syscat.tables WHERE tabschema = '${table_schema}' ORDER BY tabname
            ]]>
        </SQL>   
      </Command>

      <!--
        The "getColumnNamesFor" command is used by Database getColumnNamesFor().
        It must return column names for the catalog, schema and table named by
        the ${table_catalog}, ${table_catalog} and ${table_name} variables in
        the first column.
      -->
      <Command id="db2.getColumnNamesFor">
        <SQL>
          <![CDATA[
SELECT COLNAME FROM SYSCAT.COLUMNS WHERE TABNAME = '${table_name}' AND TABSCHEMA = '${table_schema}' ORDER BY COLNAME
            ]]>
        </SQL>   
      </Command>

      <Command id="db2.getSchemas">
         <SQL>
            <![CDATA[
select * from syscat.schemata order by schemaname
            ]]>
         </SQL>
         <!--The columns are padded with whitespace up to the column lengths. -->
         <!--Need to trim here since setting a default value in actions wont work-->
         <!--as the ${schema} being set is already trimmed resulting in no match if-->
         <!--not trimming the schema column in the result set.-->
         <ProcessDataSet action="trimcolumn" index="1"/>
      </Command>

      <Command id="db2.getSchemaNames">
         <SQL>
            <![CDATA[
select * from syscat.schemata order by schemaname
            ]]>
         </SQL>
         <!--The columns are padded with whitespace up to the column lengths. -->
         <!--Need to trim here since setting a default value in actions wont work-->
         <!--as the ${schema} being set is already trimmed resulting in no match if-->
         <!--not trimming the schema column in the result set.-->
         <ProcessDataSet action="trimcolumn" index="1"/>
         <!--Must have Filter element here since this command is fetched from code-->
         <Filter index="schemaname" label="Name"/>
      </Command>

      <Command id="db2.getTables">
         <SQL>
            <![CDATA[
select * from syscat.tables where tabschema = '${owner}' and tabname like '${table}' and type like '${type}' order by tabname
            ]]>
         </SQL>
      </Command>
      
       <Command id="db2.getAliases">
         <SQL>
            <![CDATA[
            Select T.TABNAME as "Alias Name", 
                 T.TABSCHEMA as "Alias Schema", 
                 T.Owner as "Alias Owner", 
                 T1.TABNAME as "Target Name", 
                 T1.TABSCHEMA as "Target Schema",
                  CASE
                   WHEN T1.TYPE = 'V' THEN 'View'
                   WHEN T1.TYPE = 'T' THEN 'Table'
                   WHEN T1.TYPE = 'S' THEN 'MaterializedQueryTable'
                   WHEN T1.TYPE IS NULL THEN 'Unknown'
                   ELSE 'Unknown'
                 END as "Target Type", 
                 T.REMARKS as "Comment",  
            ]]>
         <If test="#util.isDatabaseVersionGT(9,1)">
            <![CDATA[
                 T.CREATE_TIME as "Alias Create Time",
                 T.ALTER_TIME as "Alias Alter Time"
            ]]>
         </If>
         <Else>               
            <![CDATA[
                 T.CREATE_TIME as "Alias Create Time"
            ]]>
         </Else>
            <![CDATA[
            from syscat.tables T INNER JOIN syscat.tables T1 
    ON T.BASE_TABSCHEMA = T1.TABSCHEMA 
    AND T.BASE_TABNAME = T1.TABNAME
    WHERE T.TYPE = 'A' AND T1.TYPE IN ('T', 'V' , 'S') 
    AND T.TABSCHEMA = '${owner}' 
    AND T.tabname like '${table}' order by T.TABNAME;
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getColumns">
         <SQL>
            <![CDATA[
select * from syscat.columns where tabschema = '${owner}' and tabname = '${table}' order by colno
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getViews">
         <SQL>
            <![CDATA[
select v.viewschema,v.viewname,v.definer,v.seqno,v.viewcheck,v.readonly,v.valid,v.qualifier,t.remarks,func_path from syscat.views v, syscat.tables t where v.viewschema = t.tabschema and v.viewname = t.tabname and t.type = '${type}' and v.viewschema = '${owner}' and v.viewname like '${view}' order by v.viewname
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getViewSource">
         <SQL>
            <![CDATA[
select text from syscat.views where viewschema = '${owner}' and viewname = '${view}'
            ]]>
         </SQL>
      </Command>

     <!-- Getting the triggers is done in two ways --> 
     <!--    For triggers specific to a table -> triggerCondition is: "and tabname = '${theTableName}'"   -->
     <!--    For all triggers (triggers on the tables in the schema and triggers own by the schema )      -->
     <!--          triggerCondition is: -> "or trigschema = '${schema}'                                    -->
      <Command id="db2.getTriggers">
         <SQL>
            <![CDATA[
select trigschema,trigname,definer,tabschema,tabname,trigtime,trigevent,granularity,valid,create_time,qualifier,func_path,remarks from syscat.triggers 
where tabschema = '${tabSchema}' ${triggerCondition} order by trigschema, trigname
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getTableTriggers">
         <SQL>
            <![CDATA[
select * from syscat.triggers where tabschema = '${tabSchema}' ${triggerCondition} order by trigschema, trigname
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getTableTriggerSource">
         <SQL>
            <![CDATA[
select text from syscat.triggers where trigSchema = '${trigSchema}' and trigname = '${name}'
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getTableConstraints">
         <SQL>
            <![CDATA[
SELECT t.constname "Name", t.definer "Definer", CASE WHEN t.type = 'F' THEN 'Foreign Key' WHEN t.type = 'P' THEN 'Primary Key' WHEN t.type = 'I' THEN 'Functional Dependency' WHEN t.type = 'K' THEN 'Check'  WHEN t.type = 'U' THEN 'Unique' ELSE t.type END "Type", t.remarks "Remarks", varchar(c.text) "Check Condition" FROM syscat.tabconst t LEFT OUTER JOIN syscat.checks c ON t.constname = c.constname and t.tabschema = c.tabschema and t.tabname = c.tabname WHERE t.tabschema = '${owner}' and t.tabname = '${table}' order by t.constname]]>
         </SQL>
      </Command>

      <Command id="db2.getIndexes">
         <If test="#util.isDatabaseVersionGTE(9,7)">
            <SQL>
            <![CDATA[
select i.*, 
  case when ipt.indname is null then 'FALSE' else 'TRUE' end as PARTITIONED,
  case when ipt.indname is not null then dpe.datapartitionexpression else null end as datapartitionexpression
from syscat.indexes i
left join (
  select DISTINCT indschema, indname, tabschema, tabname
  from syscat.indexpartitions ) as ipt
  on (ipt.indschema = i.indschema
      and ipt.indname = i.indname
      and ipt.tabschema = i.tabschema
      and ipt.tabname = i.tabname)
left join syscat.datapartitionexpression dpe
  on (i.tabschema = dpe.tabschema
      and i.tabname = dpe.tabname)
where ${indexCondition}
${userDefinedCond} 
order by indschema, indname
            ]]>
            </SQL>
         </If>
         <Else>
            <SQL>
            <![CDATA[
select * from syscat.indexes i
   where ${indexCondition} ${userDefinedCond} order by indschema, indname
            ]]>
            </SQL>
         </Else>
      </Command>

      <Command id="db2.getIndexColumns">
         <SQL>
            <![CDATA[
select * from syscat.indexcoluse where indschema = '${owner}' and indname = '${name}' order by indname, colseq
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getSystemTables">
         <SQL>
            <![CDATA[
select * from syscat.tables where tabschema = '${owner}' order by tabschema, tabname
            ]]>
         </SQL>
         <Input name="owner" value="${getSchemas.TABLE.SCHEM}"/>
      </Command>

      <Command id="db2.getPackages">
         <SQL>
            <![CDATA[
select * from syscat.packages where pkgschema = '${owner}' order by pkgschema, pkgname
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getFunctions">
         <SQL>
            <![CDATA[
select * from syscat.functions where funcschema = '${owner}' order by funcschema, funcname
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getFunctionParms">
         <SQL>
            <![CDATA[
select * from syscat.funcparms where funcschema = '${owner}' and funcname = '${function}' and rowtype in (${rowtype}) and specificname like '${specificname}' order by specificname, ordinal
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getProcedures">
         <SQL>
            <![CDATA[
select * from syscat.procedures where procschema = '${owner}' order by procschema, procname
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getProcedureParms">
         <SQL>
            <![CDATA[
select * from syscat.procparms where procschema = '${owner}' and procname = '${procedure}' and specificname like '${specificname}' order by specificname, ordinal
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getSequences">
         <SQL>
            <![CDATA[
select * from syscat.sequences where seqschema = '${owner}' and seqtype = 'S' order by seqname
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getSequencePrivileges">
         <SQL>
            <![CDATA[
select * from syscat.sequenceauth where seqname = '${name}' and seqschema = '${owner}'
            ]]>
         </SQL>
      </Command>

      <!-- ================================================================= -->
      <!-- DBA related commands requiring certain privileges in the database -->
      <!-- ================================================================= -->

      <Command id="db2.getGrantees">
         <SQL>
            <![CDATA[
select * from syscat.dbauth where granteetype = '${granteetype}' and grantee like '${grantee}'
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getAuth">
         <SQL>
            <![CDATA[
select * from syscat.${table} where grantee = '${grantee}'
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getTableSpaces">
         <SQL>
            <![CDATA[
select * from syscat.tablespaces
            ]]>
         </SQL>
      </Command>

      <!--select * from table (SNAPSHOT_LOCK(current server, -1)) tab-->

      <Command id="db2.getSnapshotLocks">
         <SQL>
            <![CDATA[
SELECT locks.table_schema, locks.table_name, locks.lock_object_type, users.agent_id, users.appl_name, users.client_nname, users.auth_id, users.execution_id, users.db_name, locks.lock_mode, locks.lock_status, locks.lock_object_name, locks.lock_escalation FROM TABLE (SNAPSHOT_APPL_INFO(current server, -1)) users INNER JOIN TABLE (SNAPSHOT_LOCK(current server, -1)) locks ON users.agent_id = locks.agent_id ORDER BY locks.table_schema, users.execution_id, users.auth_id, users.agent_id, locks.table_name
         ]]>
         </SQL>
      </Command>

      <Command id="db2.getRoles">
         <SQL>
            <![CDATA[
SELECT * FROM SYSCAT.ROLES ORDER BY ROLENAME
         ]]>
         </SQL>
      </Command>

      <Command id="db2.getRolesForGrantee">
         <SQL>
            <![CDATA[
SELECT * FROM syscat.roles WHERE roleid IN (SELECT roleid FROM syscat.roleauth WHERE grantee = '${grantee}')
            ]]>
         </SQL>
      </Command>

      <Command id="db2.getGranteeTypeForRole">
         <SQL>
            <![CDATA[
SELECT * FROM syscat.dbauth WHERE grantee in (SELECT grantee from syscat.roleauth WHERE rolename = '${grantee}') AND granteetype = '${granteetype}'
            ]]>
         </SQL>
      </Command>
   </Commands>

   <!-- =================================================================== -->
   <!-- Definition of the object actions that are used by the tree and views -->
   <!-- =================================================================== -->

   <ObjectsActionDef extends="false">

      <ActionGroup type="Schemas">
         <Action id="db2-schemas-create" label="Create Schema" reload="true"
                 resetschemas="true" icon="add">
            <Input label="Schema Name" name="schemaName" style="text"/>
            <Input label="Authorization Name" name="osUserid" style="text"/>
             <SetVar name="_authorization" value="#osUserid.equals('') ? '' : 'authorization ${osUserid}'"/>
            
            <Command>
              <SQL><![CDATA[create schema ${QB}${schemaName}${QE} ${_authorization}]]></SQL>
            </Command>
            <Result>
               Schema ${schemaName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Schema">
         <Action id="db2-schema-drop" label="Drop Schema" reload="true"
                 resetschemas="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Command><SQL><![CDATA[drop schema "${schema}" restrict]]></SQL></Command>
            <Confirm>
               Really drop schema ${schema}?
            </Confirm>
            <Result>
               Schema ${schema} has been dropped!
            </Result>
         </Action>

         <Action id="db2-schema-comment" label="Comment Schema">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>
                  <Command>
                     <SQL><![CDATA[select remarks from syscat.schemata where schemaname = '${schema}']]></SQL>
                  </Command>
               </Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on schema "${schema}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}?
            </Confirm>
         </Action>
         <Action id="db2-schema-export" label="Export Schema"
                 icon="export" reload="false"
                 class="schemaExport"
                 doclink="/doclink/export-schema"/>
      </ActionGroup>

      <ActionGroup type="Tables">
         <Action id="db2-tables-create-table" label="Create Table"
                 icon="add" reload="true"
                 class="tableCreateOrAlter"
                 classargs="create"
                 doclink="/doclink/create-table"/>
         <Action id="db2-tables-import-table-data"
                 label="Import Table Data"
                 icon="import"
                 reload="true"
                 class="tableDataImport"
                 doclink="/doclink/import-table"/>
        </ActionGroup>

      <ActionGroup type="Table">
         <Action id="db2-tables-alter-table" label="Alter Table"
                 icon="edit" reload="true"
                 class="tableCreateOrAlter"
                 classargs="alter"
                 doclink="/doclink/alter-table"/>

         <Action id="db2-table-rename" label="Rename Table" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Table Name" name="newTable" style="text"/>
            <Command>
               <SQL><![CDATA[rename table "${schema}"."${objectname}" to ${QB}${newTable}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of ${schema}.${objectname} to ${QB}${newTable}${QE}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} renamed to ${newTable}!
            </Result>
         </Action>

         <Action id="db2-table-clear" label="Empty Table" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>

            <!--DBVIS-1374 The "Empty Table" action used to truncate a table doesn't work in DB2 9.7-->
             <If test="#util.isDatabaseVersionGTE(9,7)">
               <Input label="Use Command" name="useCommand" style="radio">
                  <Values>TRUNCATE|DELETE</Values>
                  <Default>TRUNCATE</Default>
               </Input>
            </If>

            <SetVar name="_command" value="#useCommand != null and #useCommand.equals('TRUNCATE') ? 'truncate table' : 'delete from'"/>

            <!--DBVIS-1374 The "Empty Table" action used to truncate a table doesn't work in DB2 9.7-->
             <If test="#util.isDatabaseVersionGTE(9,7)">
               <SetVar name="_immediate" value="#_command.startsWith('truncate') ? 'immediate' : ''"/>
            </If>
            <Else>
               <SetVar name="_immediate" value="''"/>
            </Else>

            <Command>
               <SQL><![CDATA[${_command} "${schema}"."${objectname}" ${_immediate}]]></SQL>
            </Command>
            <Confirm>
               Really remove all rows in table ${schema}.${objectname}?
            </Confirm>
            <Result>
               All rows in table ${schema}.${objectname} has been removed!
            </Result>
         </Action>

         <Action id="db2-table-drop" label="Drop Table" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Table Hierarchy" name="hierarchy" style="check">
               <Values>hierarchy</Values>
            </Input>
            <Command><SQL><![CDATA[drop table ${hierarchy} "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop table ${schema}.${objectname}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="db2-table-comment" label="Comment Table" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${getTables.REMARKS}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on table "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="db2-table-import-table-data" label="Import Table Data" icon="import"
                 class="tableDataImport"
                 doclink="/doclink/import-table"/>

         <Action id="db2-table-export" label="Export Table" icon="export"
                 class="tableExport"
                 doclink="/doclink/export-table"/>

         <Separator/>

         <Action id="db2-table-create-index" label="Create Index" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Index Schema" name="indexSchema" style="list" editable="false">
               <Default>${schema}</Default>
                <Values>
                   <Command idref="db2.getSchemas"/>
               </Values>
            </Input>
            <Input label="Index Name" name="indexname" style="text"/>
            <Input label="Unique" name="unique" style="check">
               <Values>unique</Values>
            </Input>

            <Input label="Columns" style="separator"/>

            <Input name="columns" style="grid">
               <Arg name="output" value='"${columnname}"${_sortorder}'/>
               <Arg name="newline" value=", "/>

               <Input name="columnname" label="Column Name" style="list">
                  <Values column="4">
                     <Command idref="getColumnNamesFor">
                        <Input name="table_catalog" value="${catalog}"/>
                        <Input name="table_schema" value="${schema}"/>
                        <Input name="table_name" value="${objectname}"/>
                     </Command>
                  </Values>
                  <Default>${0}</Default>
               </Input>
               <Input name="sortorder" label="Sort Order" style="radio">
                  <Labels>ASC|DESC|Default</Labels>
                  <Values>ASC|DESC|</Values>
                  <Default>ASC</Default>
               </Input>
               <SetVar name="_sortorder" value='#sortorder.equals("") ? "" : " " + #sortorder'/>
            </Input>

            <Input label="Cluster" name="cluster" style="check">
               <Values>cluster</Values>
            </Input>

            <Input label="Reverse Scan" name="scans" style="radio">
               <Labels>Default|Allow|Disallow</Labels>
               <Values>|allow|disallow</Values>
            </Input>

            <SetVar name="_unique" value='#unique.equals("") ? "" : " " + #unique'/>
            <SetVar name="_columns" value='#columns.trim().equals("") ? "" : "(" + #columns + ")"'/>
            <SetVar name="_scans" value='#scans.trim().equals("") ? "" : #scans + " reverse scans"'/>

            <Command>
               <SQL>
                  <![CDATA[
create${_unique} index "${indexSchema}".${QB}${indexname}${QE} on "${schema}"."${objectname}" ${_columns}
${cluster} ${_scans}
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               <![CDATA[Create index  "${indexSchema}"."${indexname}"?]]>
            </Confirm>
            <Result>
               <![CDATA[Index  "${indexSchema}"."${indexname}" created!]]>
            </Result>
         </Action>

         <Action id="db2-tabletrigger-create" label="Create Trigger" icon="add" reload="true"
                 doclink="/doclink/create-trigger">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Trigger Schema" name="triggerSchema" style="list" editable="false">
               <Default>${schema}</Default>
                <Values>
                   <Command idref="db2.getSchemas"/>
               </Values>
            </Input>
            <Input label="Trigger" name="triggerName" style="text"/>
            <Input label="Trigger Time" name="triggerTime" style="radio">
               <Values>BEFORE|AFTER|INSTEAD OF</Values>
               <Default>AFTER</Default>
            </Input>
            <Input label="Trigger Event" name="triggerEvent" style="radio">
               <Values>DELETE|INSERT|UPDATE</Values>
               <Default>INSERT</Default>
            </Input>
            <Input label="Trigger Type" name="triggerType" style="radio">
               <Values>STATEMENT|ROW</Values>
               <Default>STATEMENT</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Source" style="separator"/>
            <Input name="source" style="text-editor">
               <Default><![CDATA[
--
--  Insert your own trigger code here
--
    insert into anotherTable (col1, col2) values(val1, val2)]]>
               </Default>
            </Input>

            <SetVar name="refType" value='#triggerType.equals("STATEMENT") ? " table" : ""'/>
            <SetVar name="_refd" value='#triggerEvent.equals("DELETE") ? "referencing old" + #refType + " as \"OLD_" + #objectname + "\"" : ""'/>
            <SetVar name="_refi" value='#triggerEvent.equals("INSERT") ? "referencing new" + #refType + " as \"NEW_" + #objectname + "\"" : ""'/>
            <SetVar name="_refu" value='#triggerEvent.equals("UPDATE") ? "referencing old" + #refType + " as \"OLD_" + #objectname + "\" new" + #refType + " as \"NEW_" + #objectname + "\"" : ""'/>

            <SetVar name="_ref1" value="#_refi.equals('') ? #_refd : #_refi"/>
            <SetVar name="_ref2" value="#_refu.equals('') ? #_ref1 : #_refu"/>

            <SetVar name="_references" value="#triggerTime.equals('BEFORE') ? '' : '\n  ' + #_ref2"/>

            <Command exectype="asis">
               <SQL><![CDATA[
create trigger "${triggerSchema}".${QB}${triggerName}${QE}
  ${triggerTime} ${triggerEvent}
  on "${schema}"."${objectname}"${_references}
  for each ${triggerType}
${source}]]>
               </SQL>
            </Command>
            <Result>
               <![CDATA[Trigger <b>${triggerSchema}.${triggerName}</b> created.]]>
            </Result>
         </Action>

         <Separator/>

         <Action id="db2-table-script" label="Script Table" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>

      </ActionGroup>

      <ActionGroup type="Column">
         <Action id="db2-column-comment" label="Comment Column" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${theTableName}</Default>
            </Input>
            <Input label="Column" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${getColumnDefinitions.COMMENT}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on column "${schema}"."${theTableName}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${theTableName}.${objectname}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="View">
         <Action id="db2-view-drop" label="Drop View" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop view "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop view ${schema}.${objectname}?
            </Confirm>
            <Result>
               View ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="db2-view-comment" label="Comment View" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${db2.getViews.REMARKS}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on table "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="db2-view-export" label="Export View" icon="export"
                 class="viewExport"
                 doclink="/doclink/export-view"/>

         <Separator/>

         <Action id="db2-viewtrigger-create" label="Create Trigger" icon="add" reload="true"
                 doclink="/doclink/create-trigger">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Trigger Schema" name="triggerSchema" style="list" editable="false">
               <Default>${schema}</Default>
                <Values>
                   <Command idref="db2.getSchemas"/>
               </Values>
            </Input>
            <Input label="Trigger" name="triggerName" style="text"/>
            <Input label="Trigger Time" name="triggerTime" style="radio" editable="false">
               <Values>INSTEAD OF</Values>
               <Default>INSTEAD OF</Default>
            </Input>
            <Input label="Trigger Event" name="triggerEvent" style="radio">
               <Values>DELETE|INSERT|UPDATE</Values>
               <Default>INSERT</Default>
            </Input>
            <Input label="Trigger Type" name="triggerType" style="radio" editable="false">
               <Values>ROW</Values>
               <Default>ROW</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Source" style="separator"/>
            <Input name="source" style="text-editor">
               <Default><![CDATA[
--
--  Insert your own trigger code here
--
    insert into anotherTable (col1, col2) values(val1, val2)]]>
               </Default>
            </Input>

            <SetVar name="refType" value='#triggerType.equals("STATEMENT") ? " table" : ""'/>
            <SetVar name="_refd" value='#triggerEvent.equals("DELETE") ? "referencing old" + #refType + " as \"OLD_" + #objectname + "\"" : ""'/>
            <SetVar name="_refi" value='#triggerEvent.equals("INSERT") ? "referencing new" + #refType + " as \"NEW_" + #objectname + "\"" : ""'/>
            <SetVar name="_refu" value='#triggerEvent.equals("UPDATE") ? "referencing old" + #refType + " as \"OLD_" + #objectname + "\" new" + #refType + " as \"NEW_" + #objectname + "\"" : ""'/>

            <SetVar name="_ref1" value="#_refi.equals('') ? #_refd : #_refi"/>
            <SetVar name="_ref2" value="#_refu.equals('') ? #_ref1 : #_refu"/>

            <SetVar name="_references" value="#triggerTime.equals('BEFORE') ? '' : '\n  ' + #_ref2"/>

            <Command exectype="asis">
               <SQL><![CDATA[
create trigger "${triggerSchema}".${QB}${triggerName}${QE}
  ${triggerTime} ${triggerEvent}
  on "${schema}"."${objectname}"${_references}
  for each ${triggerType}
${source}]]>
               </SQL>
            </Command>
            <Result>
               <![CDATA[Trigger <b>${schema}.${triggerName}</b> created.]]>
            </Result>
         </Action>

         <Separator/>

         <Action id="db2-view-script" label="Script View" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>

      </ActionGroup>

      <ActionGroup type="TemporaryTable">
         <Action id="db2-temptab-drop" label="Drop Table" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Table Hierarchy" name="hierarchy" style="check">
               <Values>hierarchy</Values>
            </Input>
            <Command><SQL><![CDATA[drop table ${hierarchy} "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop table ${schema}.${objectname}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <!--Note: Script must be inserted in the same editor as in which the-->
         <!--temporary table was created. Reason is that the table only exist-->
         <!--for that physical connection and is invisible for other editors.-->
         <Action id="db2-temporarytable-script" label="Script Table" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>

      </ActionGroup>

      <ActionGroup type="Aliases">
         <Action id="db2-aliases-create" label="Create Alias" reload="true" icon="add">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Alias Name" name="aliasName" style="text"/>
            <Input label="Object Schema" name="objSchema" style="list">
               <Values>
                  <Command>
                     <SQL><![CDATA[select distinct rtrim(schemaname) from syscat.schemata order by 1]]></SQL>
                  </Command>
               </Values>
               <Default>${schema}</Default>
            </Input>
            <Input label="Object Name" name="objName" style="text"/>
            <Command>
              <SQL><![CDATA[create alias "${schema}".${QB}${aliasName}${QE} for "${objSchema}"."${objName}"]]></SQL>
            </Command>
            <Result>
               Alias ${schema}.${aliasName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Alias">
         <Action id="db2-alias-drop" label="Drop Alias" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Alias" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop alias "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop alias ${schema}.${objectname}?
            </Confirm>
            <Result>
               Alias ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="db2-alias-comment" label="Comment Alias" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Alias" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${db2.getAliases.Comment}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on alias "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Separator/>

         <Action id="db2-alias-script" label="Script Alias" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE"/>

      </ActionGroup>

      <ActionGroup type="Nickname">
         <Action id="db2-nickname-drop" label="Drop Nickname" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Nickname" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop nickname "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop nickname ${schema}.${objectname}?
            </Confirm>
            <Result>
               Nickname ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="db2-nickname-comment" label="Comment Nickname" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Nickname" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>
                  <Command>
                     <SQL><![CDATA[select remarks from syscat.tables where tabschema = '${schema}' and tabname = '${objectname}']]></SQL>
                  </Command>
               </Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on nickname "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Separator/>

         <Action id="db2-nickname-script" label="Script Nickname" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE"/>

      </ActionGroup>

      <ActionGroup type="Index">
         <Action id="db2-index-drop" label="Drop Index" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Index" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop index "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop index ${schema}.${objectname}?
            </Confirm>
            <Result>
               Index ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="db2-index-rename" label="Rename Index" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Index" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Index Name" name="newIndex" style="text"/>
            <Command>
               <SQL><![CDATA[rename index "${schema}"."${objectname}" to ${QB}${newIndex}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of index ${schema}.${objectname} to ${newIndex}?
            </Confirm>
            <Result>
               Index ${objectname} renamed to ${newIndex}!
            </Result>
         </Action>

         <Action id="db2-index-comment" label="Comment Index" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Index" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>
                  <Command>
                     <SQL><![CDATA[select remarks from syscat.indexes where indschema = '${schema}' and indname = '${objectname}']]></SQL>
                  </Command>
               </Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on index "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Separator/>

         <Action id="db2-index-script" label="Script Index" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="Sequences">
         <Action id="db2-sequences-create" label="Create Sequence" reload="true" icon="add">
            <Input label="Sequence Owner" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence Name" name="sequenceName" style="text"/>
            <Input label="Data Type" name="dataType" style="list">
               <Values>INTEGER|SMALLINT|BIGINT|DECIMAL</Values>
               <Default>INTEGER</Default>
            </Input>
            <Input label="Start With" name="startWith" style="text">
               <Default>1</Default>
            </Input>
            <Input label="Increment By" name="increment" style="text">
               <Default>1</Default>
            </Input>
            <Input label="Min Value" name="minValue" style="text">
               <Default></Default>
            </Input>
            <Input label="Max Value" name="maxValue" style="text">
               <Default></Default>
            </Input>
            <Input label="Cached Values" name="cache" style="text">
               <Default>20</Default>
            </Input>
            <Input label="Cycle" name="cycle" style="radio">
               <Values>no cycle|cycle</Values>
               <Labels>No Cycle|Cycle</Labels>
               <Default>no cycle</Default>
            </Input>
            <Input label="Order" name="order" style="radio">
               <Values>no order|order</Values>
               <Labels>No Order|Order</Labels>
               <Default>no order</Default>
            </Input>

            <SetVar name="_minValue" value="#minValue.trim().equals('') ? 'no minvalue' : 'minvalue ' + #minValue"/>
            <SetVar name="_maxValue" value="#maxValue.trim().equals('') ? 'no maxvalue' : 'maxvalue ' + #maxValue"/>

            <Command><SQL><![CDATA[create sequence "${schema}".${QB}${sequenceName}${QE} as ${dataType} start with ${startWith} increment by ${increment} ${_minValue} ${_maxValue} ${cycle} cache ${cache} ${order}]]></SQL></Command>
            <Result>
               Sequence ${schema}.${sequenceName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Sequence">
         <Action id="db2-sequence-drop" label="Drop Sequence" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Restrict" name="restrict" style="check">
               <Values>restrict</Values>
               <Default>restrict</Default>
            </Input>
            <Command><SQL><![CDATA[drop sequence "${schema}"."${objectname}" ${restrict}]]></SQL></Command>
            <Confirm>
               Really drop sequence ${schema}.${objectname}?
            </Confirm>
            <Result>
               Sequence ${schema}.${objectname} dropped!
            </Result>
         </Action>
         
         <Action id="db2-sequence-comment" label="Comment Sequence" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>
                  <Command>
                     <SQL><![CDATA[select remarks from syscat.sequences where seqschema = '${schema}' and seqtype = 'S' and SEQNAME = '${objectname}']]></SQL>
                  </Command>
               </Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on sequence "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

      </ActionGroup>

      <ActionGroup type="MaterializedQueryTable">
         <Action id="db2-materializedquerytable-drop" label="Drop Materialized Query Table" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Materialized Query Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop table "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop materialized query table ${schema}.${objectname}?
            </Confirm>
            <Result>
               Materialized query table ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="db2-materializedquerytable-comment" label="Comment Materialized Query Table" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Materialized Query Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>
                  <Command>
                     <SQL><![CDATA[select remarks from syscat.tables where tabschema = '${schema}' and tabname = '${objectname}']]></SQL>
                  </Command>
               </Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on table "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="db2-materializedquerytable-refresh" label="Refresh Materialized Query Table" reload="true">
            <Message type="info">Only possible on</Message>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Materialized Query Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>

            <Command>
               <SQL><![CDATA[refresh table "${schema}"."${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Really refresh materialized query table ${schema}.${objectname}?
            </Confirm>
            <Result>
               Materialized query table ${schema}.${objectname} has been refreshed!
            </Result>
         </Action>

         <Separator/>

         <Action id="db2-materializedquerytable-script" label="Script Materialized Query Table" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE"/>

      </ActionGroup>

      <ActionGroup type="Functions">
         <Action id="db2-functions-create" label="Create Function" reload="true" icon="add"
                 doclink="/doclink/create-function">
             <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function Name" name="functionName" style="text"/>
            <Input label="Return Data Type" name="returns" style="text">
               <Default>VARCHAR(20)</Default>
            </Input>

            <Input label="Parameters" style="separator"/>

            <Input name="parameters" style="grid">
               <Arg name="output" value="${QB}${name}${QE} ${type}"/>
               <Arg name="newline" value=", "/>

               <Input name="name" label="Name" style="text">
                  <Default>parm</Default>
               </Input>
               <Input name="type" label="Type" style="text">
                  <Default>VARCHAR(20)</Default>
               </Input>
            </Input>

            <SetVar name="_parameters" value='#parameters.trim().equals("") ? "()" : "(" + #parameters + ")"'/>
<!--
            <Input label="Source" style="separator"/>
            <Input name="source" style="text-editor">
               <Default>
                  <![CDATA[
RETURN SELECT CONCAT('Hello, ', CURRENT USER) FROM SYSIBM.SYSDUMMY1
                  ]]>
               </Default>
            </Input>
-->
            <Command exectype="asis">
               <SQL>
                  <![CDATA[
CREATE FUNCTION "${schema}".${QB}${functionName}${QE}
${_parameters}
RETURNS ${returns}
LANGUAGE SQL
RETURN SELECT CONCAT('Hello, ', CURRENT USER) FROM SYSIBM.SYSDUMMY1
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Create function ${functionOwner}.${functionName}?
            </Confirm>
            <Result>
               Function ${functionOwner}.${functionName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Function">
         <Action id="db2-function-drop" label="Drop Function" reload="true" icon="remove">
         <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop specific function "${schema}"."${db2.getFunctions.SPECIFICNAME}"]]></SQL></Command>
            <Confirm>
               Really drop function ${schema}.${objectname}?
            </Confirm>
            <Result>
               Function ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="db2-function-comment" label="Comment Function" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${db2.getFunctions.REMARKS}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on specific function "${schema}"."${db2.getFunctions.SPECIFICNAME}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="db2-function-export" label="Export Function" icon="export"
                 class="functionExport"
                 doclink="/doclink/export-code-object"/>

         <Separator/>

         <Action id="db2-function-script" label="Script Function" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,CALL,CREATE,DROP"/>

      </ActionGroup>

      <ActionGroup type="Procedures">
         <Action id="db2-procedures-create" label="Create Procedure" reload="true" icon="add"
                 doclink="/doclink/create-procedure">
             <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Procedure Name" name="procedureName" style="text"/>

            <Input label="Parameters" style="separator"/>

            <Input name="parameters" style="grid">
               <Arg name="output" value="${direction} ${QB}${name}${QE} ${type}"/>
               <Arg name="newline" value=", "/>

               <Input name="name" label="Name" style="text">
                  <Default>parm</Default>
               </Input>
               <Input name="direction" label="Direction" style="list">
                  <Values>IN|INOUT|OUT</Values>
                  <Default>IN</Default>
               </Input>
               <Input name="type" label="Type" style="text">
                  <Default>VARCHAR(20)</Default>
               </Input>
            </Input>

            <SetVar name="_parameters" value='#parameters.trim().equals("") ? "()" : "(" + #parameters + ")"'/>
<!--
            <Input label="Source" style="separator"/>
            <Input name="source" style="text-editor">
               <Default>
                  <![CDATA[
LANGUAGE SQL
BEGIN
  DECLARE v CHAR(10);
  SELECT CURRENT USER INTO v FROM SYSIBM.SYSDUMMY1;
END
                  ]]>
               </Default>
            </Input>
-->
            <Command exectype="asis">
               <SQL>
                  <![CDATA[
CREATE PROCEDURE "${schema}".${QB}${procedureName}${QE}
${_parameters}
LANGUAGE SQL
BEGIN
  DECLARE v CHAR(10);
  SELECT CURRENT USER INTO v FROM SYSIBM.SYSDUMMY1;
END
               ]]>
               </SQL>
            </Command>
            <Confirm>
               Create procedure ${procedureOwner}.${procedureName}?
            </Confirm>
            <Result>
               Procedure ${procedureOwner}.${procedureName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Procedure">
         <Action id="db2-procedure-drop" label="Drop Procedure" reload="true" icon="remove">
         <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Procedure" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop specific procedure "${schema}"."${db2.getProcedures.SPECIFICNAME}"]]></SQL></Command>
            <Confirm>
               Really drop procedure ${schema}.${objectname}?
            </Confirm>
            <Result>
               Procedure ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="db2-procedure-comment" label="Comment Procedure" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Procedure" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${db2.getProcedures.REMARKS}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on specific procedure "${schema}"."${db2.getProcedures.SPECIFICNAME}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="db2-procedure-export" label="Export Procedure" icon="export"
                 class="procedureExport"
                 doclink="/doclink/export-code-object"/>

         <Separator/>

         <Action id="db2-procedure-script" label="Script Procedure" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,CALL,CREATE,DROP"/>

      </ActionGroup>

      <ActionGroup type="DB2Package">
         <Action id="db2-package-drop" label="Drop Package" reload="true" icon="remove">
         <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Package" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop package "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop package ${schema}.${objectname}?
            </Confirm>
            <Result>
               Procedure ${schema}.${objectname} dropped!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Trigger">
         <Action id="db2-trigger-drop" label="Drop Trigger" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Trigger" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop trigger "${schema}"."${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop trigger ${schema}.${objectname}?
            </Confirm>
            <Result>
               Trigger ${schema}.${objectname} dropped!
            </Result>
         </Action>
         
         <Action id="db2-trigger-comment" label="Comment Trigger" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Trigger" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${db2.getTriggers.REMARKS}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[comment on trigger "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="db2-trigger-export" label="Export Trigger" icon="export"
                 class="triggerExport"
                 doclink="/doclink/export-code-object"/>

      </ActionGroup>

      <ActionGroup type="Roles">
         <Action id="db2-roles-create" label="Create Role" reload="true" icon="add">
            <Input label="Role Name" name="roleName" style="text"/>
            <Command>
              <!-- Do not use delimited identifier because they cannot be used when
                   granting privileges to the role -->
              <SQL><![CDATA[create role ${roleName}]]></SQL>
            </Command>
            <Result>
               Role ${roleName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Role">
         <Action id="db2-role-drop" label="Drop Role" reload="true" icon="remove">
            <Input label="Role" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command><SQL><![CDATA[drop role "${objectname}"]]></SQL></Command>
            <Confirm>
               Really drop role ${objectname}?
            </Confirm>
            <Result>
               Role ${objectname} has been dropped!
            </Result>
         </Action>
      </ActionGroup>
   </ObjectsActionDef>

   <!-- =================================================================== -->
   <!-- Definition of the database objects tree structure -->
   <!-- This definition do not list catalogs as these are not supported -->
   <!-- by DB2. -->
   <!-- =================================================================== -->

   <ObjectsTreeDef extends="false">

      <GroupNode type="Schemas" label="Schemas">
         <DataNode type="Schema" label="${getSchemas.TABLE_SCHEM}">
            <SetVar name="schema" value="${getSchemas.TABLE_SCHEM}"/>
            <Command idref="getSchemas">
               <Filter index="TABLE_SCHEM" label="Name"/>
            </Command>

            <GroupNode type="Tables" label="Tables">
               <DataNode type="Table" label="${getTables.TABLE_NAME}">
                  <SetVar name="objectname" value="${getTables.TABLE_NAME}"/>
                  <SetVar name="rowcount" value="true"/>
                  <SetVar name="acceptInQB" value="true"/>
                  <Command idref="getTables">
                     <Input name="schema" value="${getSchemas.TABLE_SCHEM}"/>
                     <Input name="objectname" value="%"/>
                     <Input name="tableType" value="TABLE,SYSTEM TABLE"/>
                  </Command>

                  <!-- Need to keep the objectname for the current table in
                       a new variable so that the viewers will be able to pick up
                       the correct input to display -->
                  <SetVar name="theTableName" value="${objectname}"/>

                  <GroupNode type="Columns" label="Columns">
                     <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}"
                               label1="${getColumnDefinitions.TYPE_NAME}" isLeaf="true"
                               icon="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'PrimaryKey' : 'Column'"
                               tip="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'This is a primary key column' : ''">
                        <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
                        <Command idref="getColumnDefinitions">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="objectname" value="${theTableName}"/>
                           <Input name="tableType" value="Table"/>
                           <Filter index="TYPE_NAME" label="Type"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="TableIndexes" label="Indexes">
                     <DataNode type="Index" label="${db2.getIndexes.INDSCHEMA}.${db2.getIndexes.INDNAME}"
                                isLeaf="true">
                        <SetVar name="objectname" value="${db2.getIndexes.INDNAME}"/>
                        <SetVar name="schema" value="${db2.getIndexes.INDSCHEMA}"/>
                        
                        <Command idref="db2.getIndexes">
                           <Input name="indexCondition" value="(i.tabschema = '${schema}' and i.tabname = '${theTableName}')"/>
                           <Input name="userDefinedCond" value="and i.user_defined = 1"/>
                           <Filter index="TABNAME" label="Table Name"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="TableTriggers" label="Triggers">
                     <DataNode type="Trigger" label="${db2.getTriggers.TRIGSCHEMA}.${db2.getTriggers.TRIGNAME}" 
                     isLeaf="true">
                        <SetVar name="objectname" value="${db2.getTriggers.TRIGNAME}"/>
                         <SetVar name="schema" value="${db2.getTriggers.TRIGSCHEMA}"/>
                        <Command idref="db2.getTriggers">
                           <Input name="tabSchema" value="${schema}"/>
                           <Input name="triggerCondition" value="and tabname = '${theTableName}'"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
               </DataNode>
            </GroupNode>

            <GroupNode type="Views" label="Views">
               <DataNode type="View" label="${db2.getViews.VIEWNAME}">
                  <SetVar name="objectname" value="${db2.getViews.VIEWNAME}"/>
                  <SetVar name="rowcount" value="true"/>
                  <SetVar name="acceptInQB" value="true"/>
                  <Command idref="db2.getViews">
                     <Input name="owner" value="${schema}"/>
                     <Input name="view" value="%"/>
                     <Input name="type" value="V"/>
                  </Command>
                  
                  <!-- Need to keep the objectname for the current view in
                       a new variable so that the viewers will be able to pick up
                       the correct input to display -->
                  <SetVar name="theTableName" value="${objectname}"/>

                  <GroupNode type="Columns" label="Columns">
                     <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}"
                               label1="${getColumnDefinitions.TYPE_NAME}" isLeaf="true">
                        <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
                        <Command idref="getColumnDefinitions">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="objectname" value="${theTableName}"/>
                           <Input name="tableType" value="View"/>
                           <Filter index="TYPE_NAME" label="Type"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="TableTriggers" label="Triggers">
                     <DataNode type="Trigger" label="${db2.getTriggers.TRIGSCHEMA}.${db2.getTriggers.TRIGNAME}" 
                        isLeaf="true">
                        <SetVar name="objectname" value="${db2.getTriggers.TRIGNAME}"/>
                        <SetVar name="schema" value="${db2.getTriggers.TRIGSCHEMA}"/>
                        <Command idref="db2.getTriggers">
                           <Input name="tabSchema" value="${schema}"/>
                           <Input name="triggerCondition" value="and tabname = '${theTableName}'"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
               </DataNode>
            </GroupNode>

            <GroupNode type="TemporaryTables" label="Temporary Tables">
               <DataNode type="TemporaryTable" label="${db2.getTables.TABNAME}" isLeaf="true">
                  <SetVar name="objectname" value="${db2.getTables.TABNAME}"/>
                  <SetVar name="rowcount" value="true"/>
                  <SetVar name="acceptInQB" value="true"/>
                  <Command idref="db2.getTables">
                     <Input name="owner" value="${schema}"/>
                     <Input name="table" value="%"/>
                     <Input name="type" value="G"/>
                  </Command>
               </DataNode>
            </GroupNode>

            <GroupNode type="Aliases" label="Aliases">
               <DataNode type="Alias" label="${db2.getAliases.Alias Name}"
                         label1="${db2.getAliases.Target Schema}.${db2.getAliases.Target Name}">
                  <SetVar name="objectname" value="${db2.getAliases.Alias Name}"/>
                  
                  <SetVar name="rowcount" value="true"/>
                  <SetVar name="acceptInQB" value="true"/>
                  <Command idref="db2.getAliases">
                     <Input name="owner" value="${schema}"/>
                     <Input name="table" value="%"/>
                     <Filter index="Target Name" label="Table Name"/>
                  </Command>
              
                 <DataNode type="${db2.getAliases.Target Type}" 
                           label="${db2.getAliases.Target Schema}.${db2.getAliases.Target Name}"
                         isLeaf="true">
                  <SetVar name="objectname" value="${db2.getAliases.Target Name}"/>
                  <SetVar name="rowcount" value="true"/>
                  <SetVar name="acceptInQB" value="true"/>
                  <Command idref="db2.getAliases">
                     <Input name="owner" value="${schema}"/>
                     <Input name="table" value="${db2.getAliases.Alias Name}"/>
                  </Command>
               </DataNode>
              </DataNode>
            </GroupNode>
            
            <GroupNode type="Nicknames" label="Nicknames">
               <DataNode type="Nickname" label="${db2.getTables.TABNAME}" isLeaf="true">
                  <SetVar name="objectname" value="${db2.getTables.TABNAME}"/>
                  <SetVar name="rowcount" value="true"/>
                  <Command idref="db2.getTables">
                     <Input name="owner" value="${schema}"/>
                     <Input name="table" value="%"/>
                     <Input name="type" value="N"/>
                  </Command>
               </DataNode>
            </GroupNode>

            <SetVar name="theTableName" value="%"/>

            <GroupNode type="Indexes" label="Indexes">
               <DataNode type="Index" label="${db2.getIndexes.INDSCHEMA}.${db2.getIndexes.INDNAME}"
                         label1="${db2.getIndexes.TABSCHEMA}.${db2.getIndexes.TABNAME}"
                         isLeaf="true">
                  <SetVar name="objectname" value="${db2.getIndexes.INDNAME}"/>
                  <SetVar name="schema" value="${db2.getIndexes.INDSCHEMA}"/>
                  
                  <Command idref="db2.getIndexes">
                     <Input name="indexCondition" value="(i.tabschema = '${schema}' or i.indschema = '${schema}')"/>
                     <Input name="userDefinedCond" value="and i.user_defined = 1"/>
                     <Filter index="TABNAME" label="Table Name"/>
                  </Command>
               </DataNode>
            </GroupNode>

            <GroupNode type="Sequences" label="Sequences">
               <DataNode type="Sequence" label="${db2.getSequences.SEQNAME}" isLeaf="true">
                  <SetVar name="objectname" value="${db2.getSequences.SEQNAME}"/>
                  <Command idref="db2.getSequences">
                     <Input name="owner" value="${schema}"/>
                  </Command>
               </DataNode>
            </GroupNode>

            <GroupNode type="SystemTables" label="System Tables" isLeaf="true"/>

            <GroupNode type="MaterializedQueryTables" label="Materialized Query Tables">
               <DataNode type="MaterializedQueryTable" label="${db2.getViews.VIEWNAME}" isLeaf="false">
                  <SetVar name="objectname" value="${db2.getViews.VIEWNAME}"/>
                  <SetVar name="rowcount" value="true"/>
                  <SetVar name="acceptInQB" value="true"/>
                  <Command idref="db2.getViews">
                     <Input name="owner" value="${schema}"/>
                     <Input name="view" value="%"/>
                     <Input name="type" value="S"/>
                  </Command>

                  <!-- Need to keep the objectname for the current table in
                       a new variable so that the viewers will be able to pick up
                       the correct input to display -->
                  <SetVar name="theTableName" value="${objectname}"/>

                  <GroupNode type="TableIndexes" label="Indexes">
                     <DataNode type="Index" label="${db2.getIndexes.INDSCHEMA}.${db2.getIndexes.INDNAME}"
                               isLeaf="true">
                        <SetVar name="objectname" value="${db2.getIndexes.INDNAME}"/>
                        <SetVar name="schema" value="${db2.getIndexes.INDSCHEMA}"/>
                        <Command idref="db2.getIndexes">
                           <Input name="indexCondition" value="(i.tabschema = '${schema}' and i.tabname = '${theTableName}')"/>
                           <Input name="userDefinedCond" value="and i.user_defined = 1"/>
                           <Filter index="TABNAME" label="Table Name"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

               </DataNode>
            </GroupNode>

            <GroupNode type="Functions" label="Functions">
               <DataNode type="Function" label="${db2.getFunctions.FUNCNAME} (${db2.getFunctions.SPECIFICNAME})"
                         isLeaf="true">
                  <SetVar name="objectname" value="${db2.getFunctions.FUNCNAME}"/>
                  <SetVar name="getDDLName" value="${db2.getFunctions.SPECIFICNAME}"/>
                  <Command idref="db2.getFunctions">
                     <Input name="owner" value="${schema}"/>
                  </Command>
               </DataNode>
            </GroupNode>

            <GroupNode type="Procedures" label="Stored Procedures">
               <DataNode type="Procedure" label="${db2.getProcedures.PROCNAME} (${db2.getProcedures.SPECIFICNAME})"
                         isLeaf="true">
                  <SetVar name="objectname" value="${db2.getProcedures.PROCNAME}"/>
                  <SetVar name="getDDLName" value="${db2.getProcedures.SPECIFICNAME}"/>
                  <Command idref="db2.getProcedures">
                     <Input name="owner" value="${schema}"/>
                  </Command>
               </DataNode>
            </GroupNode>

            <GroupNode type="DB2Packages" label="Packages">
               <DataNode type="DB2Package" label="${db2.getPackages.PKGNAME}" isLeaf="true">
                  <SetVar name="objectname" value="${db2.getPackages.PKGNAME}"/>
                  <Command idref="db2.getPackages">
                     <Input name="owner" value="${schema}"/>
                  </Command>
               </DataNode>
            </GroupNode>

            <SetVar name="theTableName" value="%"/>

            <GroupNode type="Triggers" label="Triggers">
               <DataNode type="Trigger" label="${db2.getTriggers.TRIGSCHEMA}.${db2.getTriggers.TRIGNAME}" 
                  label1="${db2.getTriggers.TABSCHEMA}.${db2.getTriggers.TABNAME}" isLeaf="true" >
                  <SetVar name="objectname" value="${db2.getTriggers.TRIGNAME}"/>
                  <SetVar name="schema" value="${db2.getTriggers.TRIGSCHEMA}"/>
                  <Command idref="db2.getTriggers">
                     <Input name="tabSchema" value="${schema}"/>
                     <Input name="triggerCondition" value="or trigschema = '${schema}'"/>
                  </Command>
               </DataNode>
            </GroupNode>
         </DataNode>
      </GroupNode>

      <GroupNode type="DBA" label="DBA Views">
         <GroupNode type="Users" label="Users">
            <DataNode type="User" label="${db2.getGrantees.GRANTEE}" isLeaf="true">
               <SetVar name="objectname" value="${db2.getGrantees.GRANTEE}"/>
               <Command idref="db2.getGrantees">
                  <Input name="granteetype" value="U"/>
                  <Input name="grantee" value="%"/>
               </Command>
            </DataNode>
         </GroupNode>

         <GroupNode type="Groups" label="Groups">
            <DataNode type="Group" label="${db2.getGrantees.GRANTEE}" isLeaf="true">
               <SetVar name="objectname" value="${db2.getGrantees.GRANTEE}"/>
               <Command idref="db2.getGrantees">
                  <Input name="granteetype" value="G"/>
                  <Input name="grantee" value="%"/>
               </Command>
            </DataNode>
         </GroupNode>

         <If test="#util.isDatabaseVersionGTE(9,5)">
            <GroupNode type="Roles" label="Roles">
               <DataNode type="Role" label="${db2.getRoles.ROLENAME}" isLeaf="true">
                  <SetVar name="objectname" value="${db2.getRoles.ROLENAME}"/>
                  <Command idref="db2.getRoles"/>
               </DataNode>
            </GroupNode>
         </If>

         <If test="#util.isDatabaseVersionGTE(8) and #util.isDatabaseVersionLT(9,7)">
            <GroupNode type="Locks" label="Locks" isLeaf="true"/>
         </If>

         <GroupNode type="Tablespaces" label="Table Spaces" isLeaf="true"/>
      </GroupNode>

   </ObjectsTreeDef>

   <!-- =================================================================== -->
   <!-- Definition of the database objects views -->
   <!-- =================================================================== -->

   <ObjectsViewDef extends="true">

      <ObjectView type="Catalogs" drop-on-condition="always"/>
      <ObjectView type="Catalog" drop-on-condition="always"/>

      <ObjectView type="Schemas">
         <DataView id="generic-schemas-schemas" drop-on-condition="always"/>

         <DataView id="db2-schemas-schemas" icon="Schemas" label="Schemas" viewer="grid">
            <Command idref="db2.getSchemas"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Schema" drop-on-condition="always"/>

      <ObjectView type="Tables">
         <DataView id="generic-tables-tables" drop-on-condition="always"/>
         <DataView id="generic-tables-references" drop-on-condition="always"/>

         <DataView id="db2-tables-tables" icon="Tables" label="Tables" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP TABLE">
               <Input name="command" value="drop table ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>

            <Command idref="db2.getTables">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="%"/>
               <Input name="type" value="T"/>
            </Command>
         </DataView>
         <DataView id="db2-tables-references" icon="References" label="References" viewer="tables-refs"
                   doclink="/doclink/show-references">
            <Command idref="getTables">
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="%"/>
               <Input name="tableType" value="TABLE,SYSTEM TABLE"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Table">
         <DataView id="generic-table-info" drop-on-condition="always"/>
         <DataView id="generic-table-indexes" drop-on-condition="always"/>
         <DataView id="generic-table-columns" drop-on-condition="always"/>
   
         <DataView id="db2-table-info" icon="Info" label="Info" viewer="form" order-before="0">
            <Command idref="db2.getTables">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
               <Input name="type" value="T"/>
            </Command>
         </DataView>

         <DataView id="db2-table-columns" icon="Columns" label="Columns" viewer="grid" order-after="db2-table-info">
             <Command idref="db2.getColumns">
              <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-table-indexes" icon="Index" label="Indexes" viewer="grid">
            <Command idref="db2.getIndexes">
               <Input name="indexCondition" value="(i.tabschema = '${schema}' and i.tabname = '${objectname}')"/>
               <Input name="userDefinedCond" value=""/>
            </Command>
         </DataView>

         <DataView id="db2-table-triggers" icon="Trigger" label="Triggers" viewer="form">
            <Command idref="db2.getTableTriggers">
               <Input name="tabSchema" value="${schema}"/>
               <Input name="triggerCondition" value="and tabname = '${objectname}'"/>
            </Command>
         </DataView>
         <DataView id="db2-table-constraints" icon="Constraints" label="Constraints" viewer="grid">
            <Command idref="db2.getTableConstraints">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="generic-table-ddl" order-after="db2-table-constraints">
            <Input name="formatSQL" value="true"/>
            <Message/>
         </DataView>

      </ObjectView>
      
      <ObjectView type="Columns">
         <DataView id="generic-columns-columns" drop-on-condition="always"/>
         <DataView id="db2-columns-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="db2.getColumns">
              <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>
      
      <ObjectView type="Views">
         <DataView id="db2-views-views" icon="Views" label="Views" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||VIEWSCHEMA}${object||VIEWNAME}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||VIEWSCHEMA}${object||VIEWNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP VIEW">
               <Input name="command" value="drop view ${schema||VIEWSCHEMA}${object||VIEWNAME}"/>
            </Input>
            <Command idref="db2.getViews">
               <Input name="owner" value="${schema}"/>
               <Input name="view" value="%"/>
               <Input name="type" value="V"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="TemporaryTables">
         <DataView id="db2-temporarytables-temporarytables" icon="TemporaryTables" label="Temporary Tables" viewer="grid">
            <Command idref="db2.getTables">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="%"/>
               <Input name="type" value="G"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="TemporaryTable">
         <DataView id="db2-temporarytable-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-temporarytable-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="db2.getColumns">
               <Input name="owner" value="${db2.getTables.TABSCHEMA}"/>
               <Input name="table" value="${db2.getTables.TABNAME}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="View">
         <DataView id="db2-view-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-view-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="db2.getColumns">
               <Input name="owner" value="${db2.getViews.VIEWSCHEMA}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="db2-view-data" icon="Data" label="Data" viewer="table-data" doclink="/doclink/table-data"/>
         <DataView id="db2-view-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>
         <DataView id="db2-view-grants" icon="TablePrivileges" label="Grants" viewer="grid">
            <Command idref="getPrivileges">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="db2-view-trigger" icon="Trigger" label="Triggers" viewer="form">
            <Command idref="db2.getTableTriggers">
               <Input name="tabSchema" value="${schema}"/>
               <Input name="triggerCondition" value="and tabname = '${objectname}'"/>
            </Command>
         </DataView>
         <DataView id="db2-view-ddl" icon="Source" label="DDL" viewer="ddl">
            <Input name="objectType" value="View"/>
            <Input name="formatSQL" value="true"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Aliases">
         <DataView id="db2-aliases-aliases" icon="Aliases" label="Aliases" viewer="grid">
            <Command idref="db2.getAliases">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="%"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Alias">
         <DataView id="db2-alias-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Nicknames">
         <DataView id="db2-nicknames-nicknames" icon="Nicknames" label="Nicknames" viewer="grid">
            <Command idref="db2.getTables">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="%"/>
               <Input name="type" value="N"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Nickname">
         <DataView id="db2-nickname-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-nickname-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="db2.getColumns">
               <Input name="owner" value="${db2.getTables.TABSCHEMA}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="db2-nickname-data" icon="Data" label="Data" viewer="table-data" doclink="/doclink/table-data"/>
         <DataView id="db2-nickname-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>
      </ObjectView>

      <ObjectView type="MaterializedQueryTables">
         <DataView id="db2-materializedquerytables-materializedquerytables" icon="MaterializedQueryTables" label="Materialized Query Tables" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||VIEWSCHEMA}${object||VIEWNAME}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||VIEWSCHEMA}${object||VIEWNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP TABLE">
               <Input name="command" value="drop table ${schema||VIEWSCHEMA}${object||VIEWNAME}"/>
            </Input>
            <Command idref="db2.getViews">
               <Input name="owner" value="${schema}"/>
               <Input name="view" value="%"/>
               <Input name="type" value="S"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="MaterializedQueryTable">
         <DataView id="db2-materializedquerytable-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-materializedquerytable-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="db2.getColumns">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="db2-materializedquerytable-data" icon="Data" label="Data" viewer="table-data" doclink="/doclink/table-data"/>
         <DataView id="db2-materializedquerytable-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>
         <DataView id="db2-materializedquerytable-indexes" icon="Index" label="Indexes" viewer="grid">
            <Command idref="getIndexes">
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
               <ProcessDataSet action="removeisnullrows" index="INDEX_NAME"/>
            </Command>
         </DataView>
         <DataView id="db2-materializedquerytable-source" icon="Source" label="Source" viewer="text">
            <Input name="formatSQL" value="true"/>
            <Command idref="db2.getViewSource">
               <Input name="owner" value="${schema}"/>
               <Input name="view" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="SystemTables">
         <DataView id="db2-systemtables-syscat" icon="SystemTables" label="SYSCAT" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Command idref="db2.getSystemTables">
               <Input name="owner" value="SYSCAT"/>
            </Command>
         </DataView>
         <DataView id="db2-systemtables-sysfun" icon="SystemTables" label="SYSFUN" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>

            <Command idref="db2.getSystemTables">
               <Input name="owner" value="SYSFUN"/>
            </Command>
         </DataView>
         <DataView id="db2-systemtables-sysibm" icon="SystemTables" label="SYSIBM" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>

            <Command idref="db2.getSystemTables">
               <Input name="owner" value="SYSIBM"/>
            </Command>
         </DataView>
         <DataView id="db2-systemtables-sysstat" icon="SystemTables" label="SYSSTAT" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||TABSCHEMA}${object||TABNAME}"/>
            </Input>

            <Command idref="db2.getSystemTables">
               <Input name="owner" value="SYSSTAT"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Indexes">
         <DataView id="generic-indexes-indexes" drop-on-condition="always"/>

         <DataView id="db2-indexes-indexes" icon="Indexes" label="Indexes" viewer="grid">
            <Command idref="db2.getIndexes">
               <Input name="indexCondition" value="(i.tabschema = '${schema}' or i.indschema = '${schema}')"/>
               <Input name="userDefinedCond" value="and i.user_defined = 1"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="TableIndexes">
         <!--  <DataView id="generic-indexes-indexes" drop-on-condition="always"/> -->

         <DataView id="db2-indexes-tableindexes" icon="Indexes" label="Indexes" viewer="grid">
            <Command idref="db2.getIndexes">
               <Input name="indexCondition" value="(i.tabschema = '${schema}' and i.tabname = '${objectname}')"/>
               <Input name="userDefinedCond" value="and i.user_defined = 1"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Index">
         <DataView id="db2-index-ddl" icon="Source" label="DDL" viewer="ddl">
            <Input name="objectType" value="Index"/>
            <Input name="formatSQL" value="true"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Sequences">
         <DataView id="db2-sequences-sequences" icon="Sequences" label="Sequences" viewer="grid">
            <Command idref="db2.getSequences">
               <Input name="owner" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Sequence">
         <DataView id="db2-sequence-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-sequence-grants" icon="TablePrivileges" label="Grants" viewer="grid">
            <Command idref="db2.getSequencePrivileges">
               <Input name="owner" value="${db2.getSequences.SEQSCHEMA}"/>
               <Input name="name" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Triggers">
         <DataView id="db2-triggers-triggers" icon="Triggers" label="Triggers" viewer="grid">
            <Command idref="db2.getTriggers">
               <Input name="tabSchema" value="${schema}"/>
               <Input name="triggerCondition" value="or TABSCHEMA = '${schema}'"/>
            </Command>
         </DataView>
      </ObjectView>
      
       <ObjectView type="TableTriggers">
         <DataView id="db2-table-triggers-triggers" icon="Triggers" label="Triggers" viewer="grid">
            <Command idref="db2.getTriggers">
            <Input name="tabSchema" value="${schema}"/>
               <Input name="triggerCondition" value="and tabname = '${objectname}'"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Trigger">
         <DataView classargs="TRIGGER" id="db2-trigger-triggereditor" icon="SourceEditor" label="Trigger Editor" viewer="procedure-editor"
                   doclink="/doclink/edit-code-object"/>
         <DataView id="db2-trigger-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-trigger-source" icon="Source" label="Source" viewer="text">
            <Input name="formatSQL" value="true"/>
            <Command idref="db2.getTableTriggerSource">
               <Input name="trigSchema" value="${db2.getTriggers.TRIGSCHEMA}"/>
               <Input name="name" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Procedures">
         <DataView id="generic-procedures-procedures" drop-on-condition="always"/>

         <DataView id="db2-procedures-storedprocedures" icon="Procedures" label="Stored Procedures" viewer="grid">
            <Command idref="db2.getProcedures">
               <Input name="owner" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Procedure">
         <DataView id="generic-procedure-columns" drop-on-condition="always"/>

         <DataView classargs="PROCEDURE" id="db2-procedure-procedureeditor" icon="SourceEditor" label="Procedure Editor" viewer="procedure-editor"
                   doclink="/doclink/edit-code-object"/>
         <DataView id="db2-procedure-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-procedure-interface" icon="Interface" label="Interface" viewer="form">
            <Command idref="db2.getProcedureParms">
               <Input name="owner" value="${schema}"/>
               <Input name="procedure" value="${objectname}"/>
               <Input name="specificname" value="${db2.getProcedures.SPECIFICNAME}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Functions">
         <DataView id="db2-functions-functions" icon="Functions" label="Functions" viewer="grid">
            <Command idref="db2.getFunctions">
               <Input name="owner" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Function">
         <DataView classargs="FUNCTION" id="db2-function-functioneditor" icon="SourceEditor" label="Function Editor" viewer="procedure-editor"
                   doclink="/doclink/edit-code-object">
         </DataView>
         <DataView id="db2-function-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="db2-function-parameters" icon="Input" label="Parameters" viewer="form">
            <Command idref="db2.getFunctionParms">
               <Input name="owner" value="${schema}"/>
               <Input name="function" value="${objectname}"/>
               <Input name="specificname" value="${db2.getFunctions.SPECIFICNAME}"/>
               <Input name="rowtype" value="'P'"/>
            </Command>
         </DataView>
         <DataView id="db2-function-result" icon="Output" label="Result" viewer="form">
            <Command idref="db2.getFunctionParms">
               <Input name="owner" value="${schema}"/>
               <Input name="function" value="${objectname}"/>
               <Input name="specificname" value="${db2.getFunctions.SPECIFICNAME}"/>
               <Input name="rowtype" value="'R','C'"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="DB2Packages">
         <DataView id="db2-db2packages-packages" icon="Packages" label="Packages" viewer="grid">
            <Command idref="db2.getPackages">
               <Input name="owner" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="DB2Package">
         <DataView id="db2-db2package-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <!-- DBA views -->

      <ObjectView type="Users">
         <DataView id="db2-users-users" icon="Users" label="Users" viewer="grid">
            <Command idref="db2.getGrantees">
               <Input name="granteetype" value="U"/>
               <Input name="grantee" value="%"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="User">
         <DataView id="db2-user-info" icon="Info" label="Info" viewer="node-form"/>

         <DataView id="db2-user-roles" icon="Roles" label="Roles" viewer="grid">
            <Command idref="db2.getRolesForGrantee">
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-user-schemaprivilege" icon="Privileges" label="Schema Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="schemaauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-user-tableprivilege" icon="Privileges" label="Table Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="tabauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-user-columnprivilege" icon="Privileges" label="Column Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="colauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-user-indexprivilege" icon="Privileges" label="Index Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="indexauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-user-packageprivilege" icon="Privileges" label="Package Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="packageauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-user-passthruprivilege" icon="Privileges" label="Passthru Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="passthruauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Groups">
         <DataView id="db2-groups-roles" icon="Groups" label="Roles" viewer="grid">
            <Command idref="db2.getGrantees">
               <Input name="granteetype" value="G"/>
               <Input name="grantee" value="%"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Group">
         <DataView id="db2-group-info" icon="Info" label="Info" viewer="node-form"/>

         <DataView id="db2-group-roles" icon="Roles" label="Roles" viewer="grid">
            <Command idref="db2.getRolesForGrantee">
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-group-schemaprivilege" icon="Privileges" label="Schema Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="schemaauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-group-tableprivilege" icon="Privileges" label="Table Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="tabauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-group-columnprivilege" icon="Privileges" label="Column Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="colauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-group-indexprivilege" icon="Privileges" label="Index Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="indexauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-group-packageprivilege" icon="Privileges" label="Package Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="packageauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-group-passthruprivilege" icon="Privileges" label="Passthru Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="passthruauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Roles">
         <DataView id="db2-roles-roles" icon="Groups" label="Roles" viewer="grid">
            <Command idref="db2.getRoles"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Role">
         <DataView id="db2-role-info" icon="Info" label="Info" viewer="node-form"/>

         <DataView id="db2-role-users" icon="Users" label="Users" viewer="grid">
            <Command idref="db2.getGranteeTypeForRole">
               <Input name="grantee" value="${objectname}"/>
               <Input name="granteetype" value="U"/>
            </Command>
         </DataView>

         <DataView id="db2-role-groups" icon="Groups" label="Groups" viewer="grid">
            <Command idref="db2.getGranteeTypeForRole">
               <Input name="grantee" value="${objectname}"/>
               <Input name="granteetype" value="G"/>
            </Command>
         </DataView>

         <DataView id="db2-role-schemaprivilege" icon="Privileges" label="Schema Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="schemaauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-role-tableprivilege" icon="Privileges" label="Table Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="tabauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-role-columnprivilege" icon="Privileges" label="Column Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="colauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-role-indexprivilege" icon="Privileges" label="Index Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="indexauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-role-packageprivilege" icon="Privileges" label="Package Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="packageauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="db2-role-passthruprivilege" icon="Privileges" label="Passthru Privilege" viewer="grid">
            <Command idref="db2.getAuth">
               <Input name="table" value="passthruauth"/>
               <Input name="grantee" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Locks">
         <DataView id="db2-locks-locks" icon="Locks" label="Locks" viewer="grid">
            <Command idref="db2.getSnapshotLocks"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Tablespaces">
         <DataView id="db2-tablespaces-tablespaces" icon="Tablespaces" label="Table Spaces" viewer="form">
            <Command idref="db2.getTableSpaces"/>
         </DataView>
      </ObjectView>

   </ObjectsViewDef>

</DatabaseProfile>
