Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Parse a SQL select statement

Reply
Thread Tools

Parse a SQL select statement

 
 
james zhou
Guest
Posts: n/a
 
      02-27-2004
Hi, in the project I am currently working on I need to parse a SQL
SELECT statement so that I can get all the selected elements in the
query. For example I need to parse the following stmt:
Select SUBSTR(ACCT_USAGE_DETAIL_GUIDE_VIEW.C1,1,60) AS KEY,
ACCT_USAGE_DETAIL_GUIDE_VIEW.BEGINTS,
TO_CHAR(TO_DATE(BEGINTS, 'YYYYMMDDHH24MISS') - 30,
'YYYYMMDDHH24MISS') AS XBEGINTS,
ACCT_USAGE_DETAIL_GUIDE_VIEW.CCS_ACCOUNT,
ACCT_USAGE_DETAIL_GUIDE_VIEW.REPORTING_NUMBER,
ACCT_USAGE_DETAIL_GUIDE_VIEW.ENDTS,
DECODE(ENDTS, '99999999999999', '99999999999999',
TO_CHAR(TO_DATE(ENDTS, 'YYYYMMDDHH24MISS') + 30, 'YYYYMMDDHH24MISS'))
AS XENDTS,
ACCT_USAGE_DETAIL_GUIDE_VIEW.SYMBOLIC_CATALOG_ENTR Y
from ACCT_USAGE_DETAIL_GUIDE_VIEW
where length(originating_number) = 10;

In the above example, "SUBSTR(ACCT_USAGE_DETAIL_GUIDE_VIEW.C1,1,60) AS
KEY" is the first element, and "ACCT_USAGE_DETAIL_GUIDE_VIEW.BEGINTS"
is the second element, so on and so forth. Apparently I cant use comma
as delimiter to break down the elements. Can anyone shed some lights
on this?

Thanks,
 
Reply With Quote
 
 
 
 
Lee Fesperman
Guest
Posts: n/a
 
      02-28-2004
james zhou wrote:
>
> Hi, in the project I am currently working on I need to parse a SQL
> SELECT statement so that I can get all the selected elements in the
> query. For example I need to parse the following stmt:
>
> ...
>
> In the above example, "SUBSTR(ACCT_USAGE_DETAIL_GUIDE_VIEW.C1,1,60) AS
> KEY" is the first element, and "ACCT_USAGE_DETAIL_GUIDE_VIEW.BEGINTS"
> is the second element, so on and so forth. Apparently I cant use comma
> as delimiter to break down the elements. Can anyone shed some lights
> on this?


No problem. Elements in the list are separated by commas which are not enclosed in
parentheses or quotes (single or double). This syntax is common to many languages.

--
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
================================================== ============
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ant task to iterate over output from SQL SELECT statement Kenneth Ljunggren Java 0 05-18-2005 09:01 AM
trying to use fill method with SQL select statement =?Utf-8?B?UGF1bA==?= ASP .Net 1 04-29-2004 12:01 AM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
ASP / SQL Query - Conditional SELECT Statement Guy Hocking ASP General 7 01-21-2004 08:41 PM
Select TOP sql statement with date datatypes J. Muenchbourg ASP General 5 09-12-2003 01:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57