Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / February 2004

Tip: Looking for answers? Try searching our database.

Parse a SQL select statement

Thread view: 
james zhou - 27 Feb 2004 17:23 GMT
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_ENTRY
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,
Lee Fesperman - 28 Feb 2004 02:02 GMT
> 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
[quoted text clipped - 7 lines]
> 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.

Signature

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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.