src-wad/src/org/openbravo/wad/Fields_data.xsql
author Asier Lostalé <asier.lostale@openbravo.com>
Tue, 17 Jun 2008 08:24:15 +0000
changeset 1239 e5124b398f64
parent 1096 916279c46d84
child 1605 8a0fe0193bef
permissions -rw-r--r--
fixed bug 0003976: Identifier for parameters in action button are not taken with the column with seqno=1 but the lowest one set as identifier
<?xml version="1.0" encoding="UTF-8" ?>
<!--
 *************************************************************************
 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
 * Version 1.1  with a permitted attribution clause; you may not  use this
 * file except in compliance with the License. You  may  obtain  a copy of
 * the License at http://www.openbravo.com/legal/license.html 
 * Software distributed under the License  is  distributed  on  an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific  language  governing  rights  and  limitations
 * under the License. 
 * The Original Code is Openbravo ERP. 
 * The Initial Developer of the Original Code is Openbravo SL 
 * All portions are Copyright (C) 2001-2006 Openbravo SL 
 * All Rights Reserved. 
 * Contributor(s):  ______________________________________.
 ************************************************************************
-->



<SqlClass name="FieldsData" package="org.openbravo.wad">
  <SqlMethod name="select" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT ad_column.ColumnName as realName, ad_column.ColumnName As Name, '' as NameRef, 
        'x' as xmltext, ad_reference_id as reference, ad_reference_value_id as referencevalue,
        ismandatory as required, (CASE ad_field.isActive WHEN 'N' THEN 'N' ELSE isDisplayed END) as isdisplayed, isupdateable as isupdateable,
        REPLACE(REPLACE(ad_column.defaultvalue, CHR(13), '\\n'), CHR(10), '') As defaultValue, 
        ad_column.fieldlength As fieldLength, 
        'Medio' as Text_Align, '' AS Xml_Format, 
        ad_field.displaylength, REPLACE(replace(REPLACE(REPLACE(AD_ELEMENT.columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') as columnname, 
        '' as WHERECLAUSE, ad_table.tablename, 'StringParameter' as Type, ad_column.ISSESSIONATTR, ad_column.iskey, 
        isParent, '' as ACCESSLEVEL, ad_field.isreadonly, '' as issecondarykey, ad_field.showInRelation, ad_field.isEncrypted,
        ad_field.SORTNO, ad_column.istranslated, '' as id, '' as htmltext, '' as htmltexttrl, '' as xmltexttrl, '' as tablenametrl, 
        0 AS NOWRAP, ad_column.isEncrypted AS isColumnEncrypted, ad_column.isDesencryptable, ad_reference_value_id, ad_column.ad_val_rule_id, '' AS isjasper, ad_field.isactive, '' as AD_Tab_ID, '' as parent_tab_name, '' as orgcode
      FROM ad_column left join ad_element on ad_column.ad_element_id = ad_element.ad_element_id,
           ad_field,  ad_table
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
        AND ad_column.ad_table_id = ad_table.ad_table_id 
        AND ad_column.isActive = 'Y' 
        AND upper(ad_column.columnname) <> 'BINARYDATA' 
        AND ad_tab_id = to_number(?)
      ORDER BY ad_field.SEQNO
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="set" type="constant" return="multiple">
      <SqlMethodComment>Create a registry</SqlMethodComment>
      <Sql></Sql>
  </SqlMethod>
  <SqlMethod name="selectDescription" type="preparedStatement" return="multiple">
    <SqlMethodComment>Description of the fields of a tab</SqlMethodComment>
    <Sql>
      SELECT f.Name As Name, f.isDisplayed as isdisplayed, f.isEncrypted, c.AD_REFERENCE_ID as reference, 
      c.FIELDLENGTH, 'Medio' as Text_Align, f.displaylength, c.ColumnName, f.showInRelation 
      FROM ad_field f, ad_column c 
      WHERE f.ad_column_id = c.ad_column_id 
      AND f.showInRelation = 'Y' 
      AND f.ad_tab_id = to_number(?) 
      ORDER BY f.SEQNO
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectDescriptionTrl" type="preparedStatement" return="multiple">
    <SqlMethodComment>Description of the fields of a tab</SqlMethodComment>
    <Sql>
      SELECT (CASE WHEN ft.Name IS NULL THEN '*' || f.Name ELSE ft.Name END) As Name, f.isDisplayed as isdisplayed, f.isEncrypted, c.AD_REFERENCE_ID as reference, 
      c.FIELDLENGTH, 'Medio' as Text_Align, f.displaylength, c.ColumnName, f.showInRelation 
      FROM ad_field f left join ad_field_trl ft on f.ad_field_id = ft.ad_field_id 
                                              AND ft.isactive = 'Y'
                                              AND ft.ad_language = ?, 
           ad_column c 
      WHERE f.ad_column_id = c.ad_column_id 
      AND f.showInRelation = 'Y' 
      AND f.ad_tab_id = to_number(?)    
      ORDER BY f.SEQNO
    </Sql>
    <Parameter name="adLanguage"/>
    <Parameter name="tab"/>    
  </SqlMethod>
  <SqlMethod name="selectAuxiliar" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns and name of the fields of a tab</SqlMethodComment>
    <Sql>
      SELECT AD_AUXILIARINPUT_ID as reference, name as realname, name as columnname, name as name, 
      code as defaultValue, 'x' as xmltext, '' as WHERECLAUSE
      FROM ad_auxiliarinput 
      WHERE ad_tab_id = to_number(?)
    </Sql>
    <Parameter name="sql" optional="true" after="WHERE " text="code LIKE ? || '%' AND "/>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="tabName" type="preparedStatement" return="string">
    <SqlMethodComment>Name of the tab</SqlMethodComment>
    <Sql>
        SELECT Name FROM ad_tab
        WHERE ad_tab_id = to_number(?)
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="windowName" type="preparedStatement" return="string">
      <SqlMethodComment>Name of the window</SqlMethodComment>
      <Sql>
        SELECT ad_window.Name FROM ad_tab, ad_window
        WHERE ad_window.ad_window_id = ad_tab.ad_window_id and ad_tab_id = to_number(?)
      </Sql>
      <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="tableKeyColumnName" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the column key of the tab</SqlMethodComment>
      <Sql><![CDATA[
        SELECT ad_column.ColumnName As Name 
        FROM ad_table, ad_column 
        WHERE ad_table.ad_table_id = ad_column.ad_table_id
          AND UPPER(ad_table.tablename) = UPPER(?) 
          AND ad_column.isActive = 'Y'
          and ad_column.iskey='Y'
        UNION
        SELECT ad_column.ColumnName As Name 
        FROM ad_table, ad_column 
        WHERE ad_table.ad_table_id = ad_column.ad_table_id
          AND UPPER(ad_table.tablename) = UPPER(?) 
          AND ad_column.isActive = 'Y'
          and ad_column.issecondarykey='Y'
      ]]></Sql>
      <Parameter name="tablename"/>
      <Parameter name="tablename"/>
  </SqlMethod>
  <SqlMethod name="keyColumnName" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the column key of the tab</SqlMethodComment>
      <Sql><![CDATA[
        SELECT ColumnName As Name, issecondarykey FROM ad_table, ad_column, ad_tab 
        WHERE ad_table.ad_table_id = ad_column.ad_table_id
          AND ad_tab.ad_table_id = ad_table.ad_table_id
          AND ad_tab_id = to_number(?) 
          and (iskey='Y' OR isSecondaryKey='Y')
          AND ad_column.ColumnName <> ? 
          ORDER BY (CASE iskey WHEN 'Y' THEN 1 ELSE 2 END)
      ]]></Sql>
      <Parameter name="tab"/>
      <Parameter name="parentField"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnNameSortTab" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql><![CDATA[
        SELECT ColumnName AS NAME, AD_REFERENCE_id AS reference, ad_reference_value_id AS referencevalue,
        (SELECT tableNAME FROM AD_TABLE, AD_TAB WHERE AD_TABLE.ad_table_id = AD_TAB.ad_table_id
        AND AD_TAB.ad_tab_id=to_number(?)) AS tablename 
        FROM AD_FIELD, AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id AND ad_table_id = to_number(?) AND isParent='Y' 
      ]]></Sql>
      <Parameter name="parentTab"/>
      <Parameter name="adTableId"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnName" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql><![CDATA[
        SELECT ColumnName AS NAME, AD_REFERENCE_id AS reference, ad_reference_value_id AS referencevalue,
        (SELECT tableNAME FROM AD_TABLE, AD_TAB WHERE AD_TABLE.ad_table_id = AD_TAB.ad_table_id
        AND AD_TAB.ad_tab_id=to_number(?)) AS tablename, to_number(?) as AD_Tab_ID, (select name from ad_tab where ad_tab_id = to_NUMBER(?)) as parent_tab_name
        FROM AD_FIELD, AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id AND ad_tab_id = to_number(?) AND isParent='Y' 
        AND EXISTS(SELECT 1 FROM AD_COLUMN c, AD_FIELD f WHERE c.ad_column_id = f.ad_column_id AND (c.iskey='Y' OR c.issecondarykey='Y')
        AND ad_tab_id=to_number(?) AND UPPER(c.columnname) = UPPER(AD_COLUMN.columnname))
      ]]></Sql>
      <Parameter name="parentTab"/>
      <Parameter name="parentTab"/>
      <Parameter name="parentTab"/>
      <Parameter name="tab"/>
      <Parameter name="parentTab"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnReal" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql>
        SELECT ColumnName AS NAME, AD_REFERENCE_id AS reference, ad_reference_value_id AS referencevalue,
        (SELECT tableNAME FROM AD_TABLE, AD_TAB WHERE AD_TABLE.ad_table_id = AD_TAB.ad_table_id
        AND AD_TAB.ad_tab_id=to_number(?)) AS tablename 
        FROM AD_FIELD, AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id AND ad_tab_id = to_number(?)
        AND UPPER(columnname) IN (SELECT UPPER(columnname) FROM AD_FIELD, AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id 
        AND AD_COLUMN.iskey='Y' 
        AND AD_FIELD.ad_tab_id=to_number(?))
      </Sql>
      <Parameter name="parentTab"/>
      <Parameter name="tab"/>
      <Parameter name="parentTab"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnRealAll" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql>
        SELECT ColumnName AS NAME, AD_REFERENCE_id AS reference, ad_reference_value_id AS referencevalue,
        (SELECT tableNAME FROM AD_TABLE, AD_TAB WHERE AD_TABLE.ad_table_id = AD_TAB.ad_table_id
        AND AD_TAB.ad_tab_id=to_number(?)) AS tablename 
        FROM AD_FIELD, AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id 
        AND ad_tab_id = to_number(?) 
        AND isparent='Y'
        order by ad_column.seqno
      </Sql>
      <Parameter name="parentTab"/>
      <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnDisplayNameSortTab" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql><![CDATA[
        SELECT ad_field.name As Name, ad_field_trl.name as columnname 
          FROM ad_field left join ad_field_trl on ad_field.ad_field_id = ad_field_trl.ad_field_id 
                                              and ad_field_trl.ad_language = ?, 
               ad_column 
        WHERE ad_field.ad_column_id = ad_column.ad_column_id 
        and ad_table_id = to_number(?) and isParent='Y' 
      ]]></Sql>
      <Parameter name="adLanguage"/>
      <Parameter name="table"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnDisplayName" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql><![CDATA[
        SELECT ad_field.name As Name, ad_field_trl.name as columnname 
          FROM ad_field left join ad_field_trl on ad_field.ad_field_id = ad_field_trl.ad_field_id 
                                              and ad_field_trl.ad_language = ?, 
               ad_column 
        WHERE ad_field.ad_column_id = ad_column.ad_column_id 
        and ad_tab_id = to_number(?) and isParent='Y' 
        and exists(select 1 from ad_column c, ad_field f where c.ad_column_id = f.ad_column_id and c.iskey='Y'
        and ad_tab_id=to_number(?) and UPPER(c.columnname) = UPPER(ad_column.columnname))
      ]]></Sql>
      <Parameter name="adLanguage"/>
      <Parameter name="tab"/>
      <Parameter name="parentTab"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnDisplayNameReal" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql>
        SELECT ad_field.Name AS NAME, AD_FIELD_TRL.NAME AS COLUMNNAME
        FROM AD_FIELD left join AD_FIELD_TRL on AD_FIELD.AD_FIELD_ID = AD_FIELD_TRL.AD_FIELD_ID
                                            AND AD_FIELD_TRL.AD_LANGUAGE = ? , 
             AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id 
        AND ad_tab_id = to_number(?)
        AND UPPER(columnname) IN (SELECT UPPER(columnname) FROM AD_FIELD, AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id 
        AND AD_COLUMN.iskey='Y' 
        AND AD_FIELD.ad_tab_id=to_number(?))
      </Sql>
      <Parameter name="adLanguage"/>
      <Parameter name="tab"/>
      <Parameter name="parentTab"/>
  </SqlMethod>
  <SqlMethod name="parentsColumnDisplayNameRealAll" type="preparedStatement" return="multiple">
      <SqlMethodComment>Name of the columns parent of the tab</SqlMethodComment>
      <Sql>
        SELECT ad_field.Name AS NAME, AD_FIELD_TRL.NAME AS COLUMNNAME
        FROM AD_FIELD left join AD_FIELD_TRL on AD_FIELD.AD_FIELD_ID = AD_FIELD_TRL.AD_FIELD_ID 
                                            AND AD_FIELD_TRL.AD_LANGUAGE = ? ,
             AD_COLUMN 
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id 
        AND ad_tab_id = to_number(?)
        AND isparent='Y'
        ORDER BY AD_Column.SEQNO
      </Sql>
      <Parameter name="adLanguage"/>
      <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="tableName" type="preparedStatement" return="string">
      <SqlMethodComment>Name of the table of the tab</SqlMethodComment>
      <Sql>
        SELECT ad_table.TABLEName FROM ad_tab, ad_table
        WHERE ad_table.ad_table_id = ad_tab.ad_table_id and ad_tab_id = to_number(?)
      </Sql>
      <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="tabNameTrl" type="preparedStatement" return="string">
      <SqlMethodComment>Name of the table of the tab</SqlMethodComment>
      <Sql>
        SELECT (CASE WHEN ad_tab_trl.Name IS NULL THEN '*' || ad_tab.Name ELSE ad_tab_trl.Name END) as NAME 
          FROM ad_tab left join ad_tab_trl on  ad_tab.ad_tab_id = ad_tab_trl.ad_tab_id
                                          and ad_tab_trl.isactive = 'Y'
                                          and ad_tab_trl.ad_language = ?
        WHERE ad_tab.ad_tab_id = to_number(?)        
      </Sql>
      <Parameter name="adLanguage"/>
      <Parameter name="tab"/>      
  </SqlMethod>
  <SqlMethod name="windowNameTrl" type="preparedStatement" return="string">
      <SqlMethodComment>Name of the table of the tab</SqlMethodComment>
      <Sql>
        SELECT (CASE WHEN ad_window_trl.Name IS NULL THEN '*' || ad_window.Name ELSE ad_window_trl.Name END) as NAME 
          FROM ad_tab, ad_window left join ad_window_trl on ad_window.ad_window_id = ad_window_trl.ad_window_id 
                                                        and ad_window_trl.isactive = 'Y'
                                                        and ad_window_trl.ad_language = ?
        WHERE ad_tab.ad_window_id = ad_window.ad_window_id 
        and ad_tab.ad_tab_id = to_number(?)
        
      </Sql>
      <Parameter name="adLanguage"/>
      <Parameter name="tab"/>      
  </SqlMethod>
  <SqlMethod name="selectUpdatables" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab that are updatables</SqlMethodComment>
    <Sql><![CDATA[
      SELECT ColumnName As Name, '?' AS Xml_Format, ad_column.ad_reference_id as reference, 
      ad_column.ad_reference_value_id as referencevalue FROM ad_field, ad_column 
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
      and UPPER(ad_column.columnname) not in ('CREATED', 'UPDATED', 'CREATEDBY', 'UPDATEDBY') 
      and ad_tab_id = to_number(?) 
      AND upper(ad_column.columnname) <> 'BINARYDATA' 
      AND ad_column.isEncrypted <> 'Y'
      AND ad_column.isactive = 'Y'
      ORDER BY ad_field.SEQNO
    ]]></Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectLists" type="preparedStatement" return="multiple">
    <SqlMethodComment>Fields of reference list in a tab</SqlMethodComment>
    <Sql>
      SELECT ColumnName As Name, 'x' as xmltext, ad_reference_value_id as referencevalue, ColumnName as NameRef, ad_table.tablename 
      FROM ad_field, ad_column, ad_table
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
        and ad_column.ad_table_id = ad_table.ad_table_id 
        and ad_field.ISDISPLAYED = 'Y'
        AND ad_tab_id = to_number(?)
        AND ad_reference_id = 17
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectTables" type="preparedStatement" return="multiple">
    <SqlMethodComment>Fields of reference table in a tab</SqlMethodComment>
    <Sql>
      SELECT ColumnName As Name, 'x' as xmltext, ad_reference_value_id as referencevalue, 
      ad_val_rule.CODE as defaultValue, ad_val_rule.AD_VAL_RULE_ID as columnname,
      ad_ref_table.WHERECLAUSE, ad_table.tablename, ad_table.name as nameref, 'TableList' as tablenametrl, 
      '18' as reference, 'Y' as required, ad_column.istranslated 
      FROM ad_field, ad_column left join ad_val_rule on ad_column.AD_VAL_RULE_ID = ad_val_rule.AD_VAL_RULE_ID , 
          ad_ref_table, ad_table 
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
      AND ad_ref_table.ad_table_id = ad_table.ad_table_id 
      AND ad_column.AD_REFERENCE_VALUE_ID = ad_ref_table.AD_REFERENCE_ID  
      and ad_field.ISDISPLAYED = 'Y'
      AND ad_tab_id = to_number(?) 
      AND ad_column.ad_reference_id = 18
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectTableDirs" type="preparedStatement" return="multiple">
    <SqlMethodComment>Fields of reference table in a tab</SqlMethodComment>
    <Sql>
      SELECT ColumnName As Name, 'x' as xmltext, ColumnName as referencevalue, 
      ad_val_rule.CODE as defaultValue, ad_val_rule.AD_VAL_RULE_ID as columnname, ad_table.tablename, 
      'TableDir' as tablenametrl, '' as WHERECLAUSE, '19' as reference, ad_column.istranslated 
      FROM ad_field, ad_column left join ad_val_rule on ad_column.AD_VAL_RULE_ID = ad_val_rule.AD_VAL_RULE_ID , ad_table 
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
      and ad_column.ad_table_id = ad_table.ad_table_id 
      and ad_field.ISDISPLAYED = 'Y'
      AND ad_tab_id = to_number(?) 
      AND ad_reference_id = 19
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="columnIdentifier" type="preparedStatement" return="string">
      <SqlMethodComment>Name of the table of the tab</SqlMethodComment>
      <Sql>
        SELECT MAX(columnname) AS NAME FROM AD_COLUMN, AD_TABLE 
        WHERE AD_TABLE.NAME = ?
          AND AD_COLUMN.ad_table_id = AD_TABLE.ad_table_id
          AND isidentifier = 'Y' 
          AND SeqNo = (CASE TO_CHAR(AD_TABLE.NAME) 
                          WHEN 'C_PaySelectionCheck' THEN 2 
                          ELSE (SELECT MIN(SeqNo) 
                                  FROM AD_Column 
                                 WHERE AD_Table_ID=AD_TABLE.AD_Table_ID 
                                   AND IsIdentifier='Y')
                           END)
      </Sql>
      <Parameter name="tableName"/>
  </SqlMethod>
  <SqlMethod name="identifierColumns" type="preparedStatement" return="multiple">
      <SqlMethodComment>identifier columns of a table</SqlMethodComment>
      <Sql>
        SELECT ad_column.columnname as name, ad_reference_id as reference, ismandatory as required, 
        REPLACE(replace(REPLACE(REPLACE(AD_ELEMENT.columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') as columnname, ad_reference_value_id as referencevalue, 
        ad_column.istranslated, ad_table.tablename 
        FROM ad_column left join ad_element on ad_column.ad_element_id = ad_element.ad_element_id, 
             ad_table 
        WHERE UPPER(ad_table.tablename) = UPPER(?)
          AND ad_column.ad_table_id = ad_table.ad_table_id
          AND isidentifier = 'Y' 
        order by seqno
      </Sql>
      <Parameter name="tableName"/>
  </SqlMethod>
  <SqlMethod name="selectSequence" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns to order by</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT ColumnName As Name
      FROM ad_field, ad_column
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
        AND ad_tab_id = to_number(?)
        AND ad_field.SORTNO is not null
      ORDER BY ad_field.SORTNO, ad_field.SEQNO
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="isSOTrx" type="preparedStatement" return="String" default="N">
    <SqlMethodComment>isSOTrx of the window</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT isSOTrx FROM AD_WINDOW, AD_TAB 
      WHERE AD_TAB.AD_WINDOW_ID = AD_WINDOW.AD_WINDOW_ID 
      AND AD_TAB.AD_TAB_ID = to_number(?)
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectDefaultValue" type="preparedStatement" return="multiple">
    <SqlMethodComment>Default values of the columns</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT ad_column.AD_COLUMN_ID as reference, ad_column.ISMANDATORY as required, 
      REPLACE(replace(REPLACE(REPLACE(columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') as Name, 
      REPLACE(REPLACE(ad_column.defaultvalue, CHR(13), '\\n'), CHR(10), '') as defaultValue, '' as WHERECLAUSE, 
      ad_reference_id as referencevalue,
      isdisplayed, ad_column.columnname as columnname, ad_table.ACCESSLEVEL, 
      ad_table.TABLENAME as NameRef, ad_reference_value_id as type, ad_column.name as realname
      FROM ad_field, ad_column, ad_table
      WHERE ad_field.ad_column_id = ad_column.ad_column_id
	  	AND ad_column.AD_TABLE_ID = ad_table.AD_TABLE_ID 
        AND ad_tab_id = to_number(?) 
        AND upper(ad_column.columnname) <> 'BINARYDATA' 
      ORDER BY ad_field.SEQNO
      ]]>
    </Sql>
    <Parameter name="sql" optional="true" after="WHERE " text="ad_column.defaultvalue LIKE ? || '%' AND "/>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectSession" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT REPLACE(replace(REPLACE(REPLACE(AD_ELEMENT.columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') as realName, REPLACE(replace(REPLACE(REPLACE(AD_ELEMENT.columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') As Name, 
        ad_reference_id as reference, ad_reference_value_id as referencevalue, 'x' as xmltext,
        ismandatory as required, isDisplayed as isdisplayed, isupdateable as isupdateable,
        ad_column.defaultvalue As defaultValue, ad_column.fieldlength As fieldLength,
        ad_field.displaylength, REPLACE(replace(REPLACE(REPLACE(AD_ELEMENT.columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') as columnname
      FROM ad_field, ad_column left join ad_element on ad_column.ad_element_id = ad_element.ad_element_id
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
        AND ad_tab_id = to_number(?)
        AND (ad_column.ISSESSIONATTR = 'Y' 
        OR ad_column.iskey = 'Y') 
        AND upper(ad_column.columnname) <> 'BINARYDATA' 
        AND ad_column.ColumnName <> 'Created'
      ORDER BY ad_field.SEQNO
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectDocumentsNo" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT ad_column.AD_COLUMN_ID as reference, REPLACE(replace(REPLACE(REPLACE(columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') as Name, 
      ad_column.defaultvalue as defaultValue, '' as WHERECLAUSE, ad_reference_id as referencevalue,
      isdisplayed, ad_column.columnname as columnname, ad_table.ACCESSLEVEL, 
      ad_table.TABLENAME as NameRef, '' as realname
      FROM ad_field, ad_column, ad_table
      WHERE ad_field.ad_column_id = ad_column.ad_column_id
	  	AND ad_column.AD_TABLE_ID = ad_table.AD_TABLE_ID 
        AND ad_tab_id = to_number(?) 
        and isParent='N'
        and ad_column.columnname = 'DocumentNo'
        and ad_column.defaultvalue is null
      ORDER BY ad_field.SEQNO
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectActionButton" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT distinct ad_column.columnname, 
      ad_column.ad_process_id as reference, ad_process.procedurename as name, 
      ad_column.ad_reference_id as type, ad_column.ad_reference_value_id as referencevalue,
      ad_val_rule_id as defaultvalue, ad_column.fieldlength, ad_field.name as realname, 
      ad_process.description as tablename, ad_process.help as xmltext, ad_column.ad_reference_value_id, ad_process.isjasper 
      FROM ad_column, ad_process, ad_field
      where ad_column.ad_process_id = ad_process.ad_process_id 
      and ad_column.ad_column_id = ad_field.ad_column_id 
      and (ad_process.procedurename is not null
      OR ad_process.isjasper = 'Y') 
      and ad_column.columnname not in('DocAction', 'PaymentRule') 
      and (ad_column.columnname <> 'CreateFrom'
      or ad_column.ad_process_id is not null)
      and (ad_column.columnname <> 'Posted'
      or ad_column.ad_process_id is not null)
      and ad_column.ad_column_id in (select ad_column_id from ad_field where isdisplayed='Y' and isactive='Y')
      and ad_column.isactive='Y'
      order by ad_column.ad_process_id
      ]]>
    </Sql>
  </SqlMethod>
  <SqlMethod name="selectActionButtonTrl" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT DISTINCT AD_COLUMN.columnname, 
        AD_COLUMN.ad_process_id AS reference, AD_PROCESS.procedurename AS NAME, 
        AD_COLUMN.ad_reference_id AS TYPE, AD_COLUMN.ad_reference_value_id AS referencevalue,
        ad_val_rule_id AS defaultvalue, AD_COLUMN.fieldlength, 
        (CASE WHEN AD_FIELD_TRL.NAME IS NULL THEN '*' || AD_FIELD.NAME ELSE AD_FIELD_TRL.NAME END) AS realname, 
        (CASE WHEN AD_PROCESS_TRL.description IS NULL THEN (CASE WHEN AD_PROCESS.DESCRIPTION IS NULL THEN '' ELSE '*' END) || AD_PROCESS.description ELSE AD_PROCESS_TRL.description END) AS tablename, 
        (CASE WHEN AD_PROCESS_TRL.help IS NULL THEN (CASE WHEN AD_PROCESS.help IS NULL THEN '' ELSE '*' END) || AD_PROCESS.help ELSE AD_PROCESS_TRL.help END) AS xmltext, 
        ad_column.ad_reference_value_id, ad_process.isjasper 
        FROM AD_FIELD left join AD_FIELD_TRL on AD_FIELD.AD_FIELD_ID = AD_FIELD_TRL.AD_FIELD_ID 
                                            AND AD_FIELD_TRL.AD_LANGUAGE = ?,
             AD_PROCESS left join AD_PROCESS_TRL on AD_PROCESS.AD_PROCESS_ID = AD_PROCESS_TRL.AD_PROCESS_ID 
                                                AND AD_PROCESS_TRL.AD_LANGUAGE = ?,
        AD_COLUMN
        WHERE AD_COLUMN.ad_process_id = AD_PROCESS.ad_process_id 
        AND AD_COLUMN.ad_column_id = AD_FIELD.ad_column_id
        AND (AD_PROCESS.procedurename IS NOT NULL
        OR AD_PROCESS.ISJASPER = 'Y')
        AND AD_COLUMN.columnname NOT IN('DocAction', 'PaymentRule')
        and (ad_column.columnname <> 'CreateFrom'
        or ad_column.ad_process_id is not null)
        and (ad_column.columnname <> 'Posted'
        or ad_column.ad_process_id is not null)
        AND AD_COLUMN.ad_column_id IN (SELECT ad_column_id FROM AD_FIELD WHERE isdisplayed='Y' AND isactive='Y')
        AND AD_COLUMN.isactive='Y'
        ORDER BY AD_COLUMN.ad_process_id
      ]]>
    </Sql>
      <Parameter name="adLanguage"/>
      <Parameter name="adLanguage"/>
  </SqlMethod>
  <SqlMethod name="selectActionButtonGenerics" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT DISTINCT 'ActionButton'  AS columnname, 
        ad_process_id AS reference, procedurename AS NAME, 
        '' AS TYPE, '' AS referencevalue,
        '' AS defaultvalue, '' AS fieldlength, '' AS realname, 
        description AS tablename, help AS xmltext, isjasper 
        FROM AD_PROCESS
        WHERE isactive='Y'
        AND (procedurename IS NOT NULL
        OR isjasper='Y')
        and ad_process_id in (select ad_process_id from ad_menu)
        ORDER BY ad_process_id
      ]]>
    </Sql>
  </SqlMethod>
  <SqlMethod name="selectActionButtonGenericsTrl" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT DISTINCT 'ActionButton'  AS columnname, 
        AD_PROCESS.ad_process_id AS reference, AD_PROCESS.procedurename AS NAME, 
        '' AS TYPE, '' AS referencevalue,
        '' AS defaultvalue, '' AS fieldlength, '' AS realname, 
        (CASE WHEN AD_PROCESS_TRL.description IS NULL THEN (CASE WHEN AD_PROCESS.description IS NULL THEN '' ELSE '*' END) || AD_PROCESS.description ELSE AD_PROCESS_TRL.description END) AS tablename, 
        (CASE WHEN AD_PROCESS_TRL.help IS NULL THEN (CASE WHEN AD_PROCESS.help IS NULL THEN '' ELSE '*' END) || AD_PROCESS.help ELSE AD_PROCESS_TRL.help END) AS xmltext, AD_PROCESS.ISJASPER 
        FROM AD_PROCESS left join AD_PROCESS_TRL on AD_PROCESS.AD_PROCESS_ID = AD_PROCESS_TRL.AD_PROCESS_ID 
                                                AND AD_PROCESS_TRL.AD_LANGUAGE  = ? 
        WHERE AD_PROCESS.isactive='Y'
        AND (AD_PROCESS.procedurename IS NOT NULL
        OR AD_PROCESS.isjasper = 'Y')
        AND AD_PROCESS.ad_process_id IN (SELECT ad_process_id FROM AD_MENU)
        ORDER BY AD_PROCESS.ad_process_id
      ]]>
    </Sql>
      <Parameter name="adLanguage"/>
  </SqlMethod>
  <SqlMethod name="isHighVolume" type="preparedStatement" return="String">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT ishighvolume FROM AD_TAB, AD_TABLE 
      WHERE AD_TAB.ad_table_id = AD_TABLE.ad_table_id
      AND AD_TAB.ad_tab_id=to_number(?)
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="isSingleRow" type="preparedStatement" return="String">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT issinglerow FROM AD_TAB 
      WHERE ad_tab_id=to_number(?)
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="hasCreateFromButton" type="preparedStatement" return="String" default="0">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT coalesce(ad_column.ad_process_id, -1) AS total 
        FROM AD_FIELD, AD_COLUMN, AD_TABLE
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id
        AND AD_COLUMN.AD_TABLE_ID = AD_TABLE.AD_TABLE_ID 
        AND ad_tab_id = to_number(?) 
        AND AD_COLUMN.ad_reference_id = 28
        AND AD_COLUMN.COLUMNNAME = 'CreateFrom'
        AND AD_COLUMN.AD_PROCESS_ID IS NULL
        AND AD_FIELD.ISDISPLAYED = 'Y'
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="hasPostedButton" type="preparedStatement" return="String" default="0">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT coalesce(ad_column.ad_process_id, -1) AS total 
        FROM AD_FIELD, AD_COLUMN, AD_TABLE
        WHERE AD_FIELD.ad_column_id = AD_COLUMN.ad_column_id
        AND AD_COLUMN.AD_TABLE_ID = AD_TABLE.AD_TABLE_ID 
        AND ad_tab_id = to_number(?) 
        AND AD_COLUMN.ad_reference_id = 28
        AND AD_COLUMN.COLUMNNAME = 'Posted'
        AND AD_COLUMN.AD_PROCESS_ID IS NULL
        AND AD_FIELD.ISDISPLAYED = 'Y'
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectValidationTab" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT c.ad_column_id as id, c.columnname, t.WHERECLAUSE as whereClause, v.code as referencevalue, c.ad_reference_id as reference,
        c.ad_reference_value_id as NameRef, c.ad_val_rule_id as defaultvalue, f.isdisplayed, c.istranslated, c.columnname as name,
        (case when t.whereclause is not null or v.code is not null then 'C' else 'R' end) as type /*Combo reaload or Reference*/ 
        FROM AD_FIELD f, 
             AD_COLUMN c left join  AD_VAL_RULE v on c.AD_VAL_RULE_ID = v.AD_VAL_RULE_ID
                         left join AD_REF_TABLE t on (CASE c.ad_reference_id WHEN 18 THEN c.AD_REFERENCE_VALUE_ID ELSE 0 END) = t.AD_REFERENCE_ID     
        WHERE f.AD_COLUMN_ID = c.ad_column_id
        AND f.ad_tab_id = to_number(?) 
        AND (t.whereclause IS NOT NULL
            OR v.code IS NOT NULL
            OR c.ad_reference_id in (19,18,17))
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectColumnTable" type="preparedStatement" return="multiple">
    <SqlMethodComment>Fields of reference table in a tab</SqlMethodComment>
    <Sql>
      SELECT ColumnName As Name, 'x' as xmltext, ad_reference_value_id as referencevalue, 
      ad_val_rule.CODE as defaultValue, ad_val_rule.AD_VAL_RULE_ID as columnname,
      ad_ref_table.WHERECLAUSE, ad_table.tablename, 'TableList' as tablenametrl, ad_table.name as nameref, 
      '18' as reference, 'Y' as required, ad_column.istranslated 
      FROM ad_field, ad_column left join ad_val_rule on ad_column.AD_VAL_RULE_ID = ad_val_rule.AD_VAL_RULE_ID, ad_ref_table, ad_table 
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
      AND ad_ref_table.ad_table_id = ad_table.ad_table_id 
      AND ad_column.AD_REFERENCE_VALUE_ID = ad_ref_table.AD_REFERENCE_ID  
      and ad_field.ISDISPLAYED = 'Y'
      AND ad_field.ad_tab_id = to_number(?)
      AND ad_column.ad_column_id = to_number(?) 
      AND ad_column.ad_reference_id = 18
    </Sql>
    <Parameter name="adTabId"/>
    <Parameter name="adColumnId"/>
  </SqlMethod>
  <SqlMethod name="selectColumnTableDir" type="preparedStatement" return="multiple">
    <SqlMethodComment>Fields of reference table in a tab</SqlMethodComment>
    <Sql>
      SELECT ColumnName As Name, 'x' as xmltext, ColumnName as referencevalue, 
      ad_val_rule.CODE as defaultValue, ad_val_rule.AD_VAL_RULE_ID as columnname, ad_table.tablename, 
      'TableDir' as tablenametrl, '' as WHERECLAUSE, '19' as reference, ad_column.istranslated 
      FROM ad_field, ad_column left join ad_val_rule on ad_column.AD_VAL_RULE_ID = ad_val_rule.AD_VAL_RULE_ID , ad_table 
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
      and ad_column.ad_table_id = ad_table.ad_table_id 
      and ad_field.ISDISPLAYED = 'Y'
      AND ad_field.ad_tab_id = to_number(?)
      AND ad_column.ad_column_id = to_number(?) 
      AND ad_reference_id = 19
    </Sql>
    <Parameter name="adTabId"/>
    <Parameter name="adColumnId"/>
  </SqlMethod>
  <SqlMethod name="columnName" type="preparedStatement" return="String" default="">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT columnname FROM AD_column 
      WHERE ad_column_id= to_number(?)
      ]]>
    </Sql>
    <Parameter name="adColumnId"/>
  </SqlMethod>
  <SqlMethod name="selectIdentify" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT ad_column.AD_COLUMN_ID as reference, REPLACE(replace(REPLACE(REPLACE(columnname, 'Substitute_ID', 'M_Product_ID'), 'C_Settlement_Cancel_ID', 'C_Settlement_ID'), 'BOM_ID', '_ID'), 'M_LocatorTo_ID', 'M_Locator_ID') as Name, 
      ad_column.defaultvalue as defaultValue, '' as WHERECLAUSE, ad_reference_id as referencevalue,
      isdisplayed, ad_column.columnname as columnname, ad_table.ACCESSLEVEL, 
      ad_table.TABLENAME as NameRef, '' as realname, ad_column.ISSESSIONATTR, ad_column.istranslated 
      FROM ad_field, ad_column, ad_table
      WHERE ad_field.ad_column_id = ad_column.ad_column_id
	  	AND ad_column.AD_TABLE_ID = ad_table.AD_TABLE_ID 
        AND ad_tab_id = to_number(?) 
        and ismandatory='Y' 
        AND upper(ad_column.columnname) = 'VALUE'
      ORDER BY ad_field.SEQNO
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectParentWhereClause" type="preparedStatement" return="String" default="">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT whereclause
      FROM ad_tab
      WHERE ad_tab_id = to_number(?) 
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="hasEncryptionFields" type="preparedStatement" return="String" default="0">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
        SELECT count(*) AS total 
        FROM AD_FIELD, AD_COLUMN
        WHERE AD_FIELD.ad_tab_id = to_number(?) 
        AND ad_field.ad_column_id = ad_column.ad_column_id 
        AND ad_column.isEncrypted = 'Y' 
        AND ad_field.ISDISPLAYED = 'Y'
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectEncrypted" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      SELECT ad_field.ad_field_id as id, ad_column.ColumnName, ad_column.ColumnName as realName, ad_column.ColumnName as Name, ad_column.isDesencryptable, '' AS Xml_Format, '' as htmltext 
      FROM ad_field, ad_column
      WHERE ad_field.ad_column_id = ad_column.ad_column_id 
        AND ad_column.isEncrypted = 'Y' 
        AND ad_field.ISDISPLAYED = 'Y'
        AND ad_tab_id = to_number(?)
      ORDER BY ad_field.SEQNO
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="selectButton" type="preparedStatement" return="multiple">
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
    <Sql>
      <![CDATA[
      select ad_reference_value_id as id, columnname, columnname || '_BTN' as realName 
      from ad_field f, ad_column c
      where f.ad_column_id = c.ad_column_id 
      and f.ad_tab_id = to_number(?)
      and f.isactive = 'Y'
      and f.isdisplayed = 'Y'
      and c.isactive = 'Y'
      and ad_reference_value_id is not null
      and c.ad_reference_id = 28 
      and c.columnname <> 'ChangeProjectStatus'
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="hasActionButton" type="preparedStatement" return="String" default="0">
    <SqlMethodComment>Checks if the tab has action buttons</SqlMethodComment>
    <Sql>
      <![CDATA[
      select count(*) as actionButtons
      from ad_field f, ad_column c
      where f.ad_column_id = c.ad_column_id 
      and f.ad_tab_id = to_number(?)
      and f.isactive = 'Y'
      and f.isdisplayed = 'Y'
      and c.isactive = 'Y'
      and ad_reference_value_id is not null
      and c.ad_reference_id = 28 
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="hasButtonList" type="preparedStatement" return="String" default="0">
    <SqlMethodComment>Checks if the tab has action buttons</SqlMethodComment>
    <Sql>
      <![CDATA[
          select count(*) as total
        from ad_field f,
             ad_column c
       where f.ad_tab_id = to_number(?)
         and f.ad_column_id = c.ad_column_id
         and ad_reference_id = 28
         and ad_reference_value_id is not null
         and f.isdisplayed = 'Y'
         and f.isactive='Y'
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  <SqlMethod name="hasButtonFixed" type="preparedStatement" return="String" default="0">
    <SqlMethodComment>Checks if the tab has action buttons</SqlMethodComment>
    <Sql>
      <![CDATA[
          select count(*) as total
        from ad_field f,
             ad_column c
       where f.ad_tab_id = to_number(?)
         and f.ad_column_id = c.ad_column_id
         and ad_reference_id = 28
         and f.isdisplayed = 'Y'
         and f.isactive='Y'
      ]]>
    </Sql>
    <Parameter name="tab"/>
  </SqlMethod>
  </SqlClass>