src-wad/src/org/openbravo/wad/Fields_data.xsql
changeset 1239 e5124b398f64
parent 1096 916279c46d84
child 1605 8a0fe0193bef
--- a/src-wad/src/org/openbravo/wad/Fields_data.xsql	Mon Jun 16 13:37:32 2008 +0000
+++ b/src-wad/src/org/openbravo/wad/Fields_data.xsql	Tue Jun 17 08:24:15 2008 +0000
@@ -367,7 +367,14 @@
         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 1 END)
+          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>