当前位置: 技术问答>java相关
一个SQL语句如何用程序判断它的列数??只查询一个表可以自动取出列数,而象下面的语句...
来源: 互联网 发布时间:2015-04-16
本文导语: SELECT WRO.WIP_ENTITY_ID, WE.WIP_ENTITY_NAME, ITEM1.SEGMENT1 ,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT1 WHERE MMT1.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT1.SUBINVENTORY_CODE = 'FGI')) FGI ,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATE...
SELECT
WRO.WIP_ENTITY_ID,
WE.WIP_ENTITY_NAME,
ITEM1.SEGMENT1
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT1 WHERE MMT1.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT1.SUBINVENTORY_CODE = 'FGI')) FGI
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT2 WHERE MMT2.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT2.SUBINVENTORY_CODE = 'MRB_FGI')) MRB_FGI
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT3 WHERE MMT3.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT3.SUBINVENTORY_CODE = 'SFG_FGI')) SFG_FGI
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT4 WHERE MMT4.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT4.SUBINVENTORY_CODE = 'SFG')) SFG,
SUM(DECODE(WDJ.START_QUANTITY - WDJ.QUANTITY_COMPLETED - WDJ.QUANTITY_SCRAPPED,0,NULL,WDJ.START_QUANTITY - WDJ.QUANTITY_COMPLETED - WDJ.QUANTITY_SCRAPPED)) "QUANTITY_REMAINING",
SUM(DECODE(WDJ.QUANTITY_COMPLETED,0,NULL,WDJ.QUANTITY_COMPLETED)) "QUANTITY_COMPLETED",
SUM(DECODE(WDJ.QUANTITY_SCRAPPED,0,NULL,WDJ.QUANTITY_SCRAPPED)) "QUANTITY_SCRAPPED",
--MMT.TRANSACTION_QUANTITY,
--MMT.SUBINVENTORY_CODE,
ITEM2.SEGMENT1 COMPONENT_ITEM,
BD.DEPARTMENT_CODE DEPARTMENT,
BD.DESCRIPTION,
WRO.DATE_REQUIRED,
WRO.QUANTITY_PER_ASSEMBLY PER_ASSEMBLY,
SUM(WRO.REQUIRED_QUANTITY) QUANTITY_REQUIRED,
SUM(DECODE(WRO.QUANTITY_ISSUED, 0,NULL, WRO.QUANTITY_ISSUED)) QUANTITY_ISSUED,
SUM(DECODE((WRO.REQUIRED_QUANTITY-WRO.QUANTITY_ISSUED), 0,NULL,DECODE(SIGN(WRO.REQUIRED_QUANTITY), -1*SIGN(WRO.QUANTITY_ISSUED),(WRO.REQUIRED_QUANTITY - WRO.QUANTITY_ISSUED),DECODE(SIGN(ABS(WRO.REQUIRED_QUANTITY) - ABS(WRO.QUANTITY_ISSUED)), -1, NULL,(WRO.REQUIRED_QUANTITY-WRO.QUANTITY_ISSUED))))) QUANTITY_OPEN,
WRO.SUPPLY_SUBINVENTORY,
ML3.MEANING SUPPLY_TYPE,
WDJ.CLASS_CODE,
ML1.MEANING JOB_TYPE,
ML2.MEANING JOB_STATUS
FROM
WIP_ENTITIES WE,
MTL_SYSTEM_ITEMS_B ITEM1,
MTL_SYSTEM_ITEMS_B ITEM2,
WIP_REQUIREMENT_OPERATIONS WRO,
BOM_DEPARTMENTS BD,
WIP_DISCRETE_JOBS WDJ,
MTL_MATERIAL_TRANSACTIONS MMT,
MFG_LOOKUPS ML1,
MFG_LOOKUPS ML2,
MFG_LOOKUPS ML3
WHERE
WE.WIP_ENTITY_ID = WDJ.WIP_ENTITY_ID
AND WDJ.WIP_ENTITY_ID = WRO.WIP_ENTITY_ID
AND ITEM2.INVENTORY_ITEM_ID = WRO.INVENTORY_ITEM_ID
AND ITEM2.ORGANIZATION_ID = WRO.ORGANIZATION_ID
AND BD.DEPARTMENT_ID = WRO.DEPARTMENT_ID
AND ITEM1.INVENTORY_ITEM_ID = WE.PRIMARY_ITEM_ID
AND ITEM1.ORGANIZATION_ID = WE.ORGANIZATION_ID
AND WDJ.WIP_ENTITY_ID = MMT.TRANSACTION_SOURCE_ID
AND MMT.TRANSACTION_TYPE_ID = 44
AND MMT.TRANSACTION_SOURCE_TYPE_ID = 5
AND ML3.LOOKUP_TYPE = 'WIP_SUPPLY'
AND ML2.LOOKUP_TYPE = 'WIP_JOB_STATUS'
AND ML1.LOOKUP_TYPE = 'WIP_DISCRETE_JOB'
AND ML1.LOOKUP_CODE = WDJ.JOB_TYPE
AND ML2.LOOKUP_CODE = WDJ.STATUS_TYPE
AND ML3.LOOKUP_CODE = WRO.WIP_SUPPLY_TYPE
AND ITEM1.ORGANIZATION_ID =4
AND ITEM2.ORGANIZATION_ID =4
AND WDJ.WIP_ENTITY_ID = 110
GROUP BY WRO.WIP_ENTITY_ID,
WE.WIP_ENTITY_NAME,
ITEM1.SEGMENT1,
ITEM2.SEGMENT1,
BD.DEPARTMENT_CODE,
BD.DESCRIPTION,
WRO.DATE_REQUIRED,
WRO.QUANTITY_PER_ASSEMBLY,
WRO.SUPPLY_SUBINVENTORY,
ML3.MEANING,
WDJ.CLASS_CODE,
ML1.MEANING,
ML2.MEANING
WRO.WIP_ENTITY_ID,
WE.WIP_ENTITY_NAME,
ITEM1.SEGMENT1
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT1 WHERE MMT1.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT1.SUBINVENTORY_CODE = 'FGI')) FGI
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT2 WHERE MMT2.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT2.SUBINVENTORY_CODE = 'MRB_FGI')) MRB_FGI
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT3 WHERE MMT3.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT3.SUBINVENTORY_CODE = 'SFG_FGI')) SFG_FGI
,SUM((SELECT TRANSACTION_QUANTITY FROM MTL_MATERIAL_TRANSACTIONS MMT4 WHERE MMT4.TRANSACTION_ID = MMT.TRANSACTION_ID AND MMT4.SUBINVENTORY_CODE = 'SFG')) SFG,
SUM(DECODE(WDJ.START_QUANTITY - WDJ.QUANTITY_COMPLETED - WDJ.QUANTITY_SCRAPPED,0,NULL,WDJ.START_QUANTITY - WDJ.QUANTITY_COMPLETED - WDJ.QUANTITY_SCRAPPED)) "QUANTITY_REMAINING",
SUM(DECODE(WDJ.QUANTITY_COMPLETED,0,NULL,WDJ.QUANTITY_COMPLETED)) "QUANTITY_COMPLETED",
SUM(DECODE(WDJ.QUANTITY_SCRAPPED,0,NULL,WDJ.QUANTITY_SCRAPPED)) "QUANTITY_SCRAPPED",
--MMT.TRANSACTION_QUANTITY,
--MMT.SUBINVENTORY_CODE,
ITEM2.SEGMENT1 COMPONENT_ITEM,
BD.DEPARTMENT_CODE DEPARTMENT,
BD.DESCRIPTION,
WRO.DATE_REQUIRED,
WRO.QUANTITY_PER_ASSEMBLY PER_ASSEMBLY,
SUM(WRO.REQUIRED_QUANTITY) QUANTITY_REQUIRED,
SUM(DECODE(WRO.QUANTITY_ISSUED, 0,NULL, WRO.QUANTITY_ISSUED)) QUANTITY_ISSUED,
SUM(DECODE((WRO.REQUIRED_QUANTITY-WRO.QUANTITY_ISSUED), 0,NULL,DECODE(SIGN(WRO.REQUIRED_QUANTITY), -1*SIGN(WRO.QUANTITY_ISSUED),(WRO.REQUIRED_QUANTITY - WRO.QUANTITY_ISSUED),DECODE(SIGN(ABS(WRO.REQUIRED_QUANTITY) - ABS(WRO.QUANTITY_ISSUED)), -1, NULL,(WRO.REQUIRED_QUANTITY-WRO.QUANTITY_ISSUED))))) QUANTITY_OPEN,
WRO.SUPPLY_SUBINVENTORY,
ML3.MEANING SUPPLY_TYPE,
WDJ.CLASS_CODE,
ML1.MEANING JOB_TYPE,
ML2.MEANING JOB_STATUS
FROM
WIP_ENTITIES WE,
MTL_SYSTEM_ITEMS_B ITEM1,
MTL_SYSTEM_ITEMS_B ITEM2,
WIP_REQUIREMENT_OPERATIONS WRO,
BOM_DEPARTMENTS BD,
WIP_DISCRETE_JOBS WDJ,
MTL_MATERIAL_TRANSACTIONS MMT,
MFG_LOOKUPS ML1,
MFG_LOOKUPS ML2,
MFG_LOOKUPS ML3
WHERE
WE.WIP_ENTITY_ID = WDJ.WIP_ENTITY_ID
AND WDJ.WIP_ENTITY_ID = WRO.WIP_ENTITY_ID
AND ITEM2.INVENTORY_ITEM_ID = WRO.INVENTORY_ITEM_ID
AND ITEM2.ORGANIZATION_ID = WRO.ORGANIZATION_ID
AND BD.DEPARTMENT_ID = WRO.DEPARTMENT_ID
AND ITEM1.INVENTORY_ITEM_ID = WE.PRIMARY_ITEM_ID
AND ITEM1.ORGANIZATION_ID = WE.ORGANIZATION_ID
AND WDJ.WIP_ENTITY_ID = MMT.TRANSACTION_SOURCE_ID
AND MMT.TRANSACTION_TYPE_ID = 44
AND MMT.TRANSACTION_SOURCE_TYPE_ID = 5
AND ML3.LOOKUP_TYPE = 'WIP_SUPPLY'
AND ML2.LOOKUP_TYPE = 'WIP_JOB_STATUS'
AND ML1.LOOKUP_TYPE = 'WIP_DISCRETE_JOB'
AND ML1.LOOKUP_CODE = WDJ.JOB_TYPE
AND ML2.LOOKUP_CODE = WDJ.STATUS_TYPE
AND ML3.LOOKUP_CODE = WRO.WIP_SUPPLY_TYPE
AND ITEM1.ORGANIZATION_ID =4
AND ITEM2.ORGANIZATION_ID =4
AND WDJ.WIP_ENTITY_ID = 110
GROUP BY WRO.WIP_ENTITY_ID,
WE.WIP_ENTITY_NAME,
ITEM1.SEGMENT1,
ITEM2.SEGMENT1,
BD.DEPARTMENT_CODE,
BD.DESCRIPTION,
WRO.DATE_REQUIRED,
WRO.QUANTITY_PER_ASSEMBLY,
WRO.SUPPLY_SUBINVENTORY,
ML3.MEANING,
WDJ.CLASS_CODE,
ML1.MEANING,
ML2.MEANING
|
取得列总数:
ResultSet lRS ;
ResultSetMetaData RSMD1 ;
Statement lStat = gConn.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE);
lRS = lStat.executeQuery(strSQL);
RSMD1 = lRS.getMetaData();
int intColumn = RSMD1.getColumnCount();
ResultSet lRS ;
ResultSetMetaData RSMD1 ;
Statement lStat = gConn.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE);
lRS = lStat.executeQuery(strSQL);
RSMD1 = lRS.getMetaData();
int intColumn = RSMD1.getColumnCount();