Hello,
I am using a StringTokenizer to isolate the "WHERE" clause in an SQL statement. This SQL statement is stored and is being returned correctly from the database, but when I do a System.out.println(stViewDef.nextToken());, not all token are listed....
Here is what I ahve so far:
and here is the SQL statement that is being returned from the database:
CREATE VIEW dbo.vwExplorerNodeProcNewUnsignDetail
AS
SELECT tblProcurement.fldProcurementKey,
tblProcurement.fldProcurementCode,
tblProcurement.fldProcurementAgentID,
tblProcurement.fldProcurementShortDesc,
tblSectionLocators.fldSectionLocatorsUnit,
tblVendor.fldVendorName,
CASE WHEN tblProcurement.fldProcurementUrgent = 1 THEN 'Yes'
ELSE 'No' END AS fldProcurementUrgent,
tblProcurement.fldPostKey,
tblProcurementType.fldProcurementTypeCode,
CASE WHEN tblActions.fldActionsKey = 3 THEN 'R' ELSE ' ' END as fldReturnIndicator
FROM tblProcurement INNER JOIN
tblSectionLocators ON
tblProcurement.fldRqstSectionLocatorsKey = tblSectionLocators.fldSectionLocatorsKey
INNER JOIN
tblActions ON
tblProcurement.fldActionsKey = tblActions.fldActionsKey LEFT
JOIN
tblVendor ON
tblProcurement.fldVendorKey = tblVendor.fldVendorKey LEFT
JOIN
tblProcurementType ON
tblProcurement.fldProcurementTypeKey = tblProcurementType.fldProcurementTypeKey
WHERE tblActions.fldActionsKey IN (1, 3) AND ((tblProcurementType.fldProcurementTypeCode = 'Z' AND
fldProcurementCOAuthKey > 0) OR (tblProcurementType.fldProcurementTypeCode <> 'Z'))
and this is what prints out when I call the System.out.println(stViewDef.nextToken()):
tblActions.fldActionsKey
(1,
AND
=
AND
fldProcurementCOAuthKey
0)
(tblProcurementType.fldProcurementTypeCode
'Z'))
Any ideas/suggestions are greatly appreciated - thanks in advance
I am using a StringTokenizer to isolate the "WHERE" clause in an SQL statement. This SQL statement is stored and is being returned correctly from the database, but when I do a System.out.println(stViewDef.nextToken());, not all token are listed....
Here is what I ahve so far:
Code:
boolean bolWhereFlag = false;
String sql = "SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '" + strView + "'"
ResultSet rResult = getQueryResult(sql);
try
{
if(rResult.next())
{
StringTokenizer stViewDef = new StringTokenizer(rResult.getString("VIEW_DEFINITION"));
while(stViewDef.hasMoreTokens())
{
if(stViewDef.nextToken().equals("WHERE") || bolWhereFlag)
{
bolWhereFlag = true;
try
{
System.out.println(stViewDef.nextToken());
}
catch(NoSuchElementException nsee)
{
System.out.println(nsee.getMessage());
}
}
}
}
closeResultSet(rResult);
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
}
CREATE VIEW dbo.vwExplorerNodeProcNewUnsignDetail
AS
SELECT tblProcurement.fldProcurementKey,
tblProcurement.fldProcurementCode,
tblProcurement.fldProcurementAgentID,
tblProcurement.fldProcurementShortDesc,
tblSectionLocators.fldSectionLocatorsUnit,
tblVendor.fldVendorName,
CASE WHEN tblProcurement.fldProcurementUrgent = 1 THEN 'Yes'
ELSE 'No' END AS fldProcurementUrgent,
tblProcurement.fldPostKey,
tblProcurementType.fldProcurementTypeCode,
CASE WHEN tblActions.fldActionsKey = 3 THEN 'R' ELSE ' ' END as fldReturnIndicator
FROM tblProcurement INNER JOIN
tblSectionLocators ON
tblProcurement.fldRqstSectionLocatorsKey = tblSectionLocators.fldSectionLocatorsKey
INNER JOIN
tblActions ON
tblProcurement.fldActionsKey = tblActions.fldActionsKey LEFT
JOIN
tblVendor ON
tblProcurement.fldVendorKey = tblVendor.fldVendorKey LEFT
JOIN
tblProcurementType ON
tblProcurement.fldProcurementTypeKey = tblProcurementType.fldProcurementTypeKey
WHERE tblActions.fldActionsKey IN (1, 3) AND ((tblProcurementType.fldProcurementTypeCode = 'Z' AND
fldProcurementCOAuthKey > 0) OR (tblProcurementType.fldProcurementTypeCode <> 'Z'))
and this is what prints out when I call the System.out.println(stViewDef.nextToken()):
tblActions.fldActionsKey
(1,
AND
=
AND
fldProcurementCOAuthKey
0)
(tblProcurementType.fldProcurementTypeCode
'Z'))
Any ideas/suggestions are greatly appreciated - thanks in advance