Parse a SQL select statement

From: james zhou (James_zhou80020_at_yahoo.com)
Date: 02/27/04


Date: 27 Feb 2004 09:23:32 -0800

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,



Relevant Pages

  • Re: Library Cache
    ... procedures that determines the SQL to be submitted based on the ... These statements would all use bind variables. ... query string to parse, whereas: ... it's HOW and WHEN that replacement occurs. ...
    (comp.databases.oracle.server)
  • Re: Library Cache
    ... procedures that determines the SQL to be submitted based on the ... These statements would all use bind variables. ... query string to parse, whereas: ... it's HOW and WHEN that replacement occurs. ...
    (comp.databases.oracle.server)
  • Re: Library Cache
    ... procedures that determines the SQL to be submitted based on the ... query string to parse, whereas: ... it's HOW and WHEN that replacement occurs. ...
    (comp.databases.oracle.server)
  • Re: Library Cache
    ... procedures that determines the SQL to be submitted based on the ... These statements would all use bind variables. ... query string to parse, whereas: ... it's HOW and WHEN that replacement occurs. ...
    (comp.databases.oracle.server)
  • Re: Advanced? Parsing Methods
    ... >and writes new records to a table in a SQL Server 2000 database. ... > there is a more efficient/advanced way to parse the data before I pass it ... have to put the results into an array. ... You can see the above recordset is MUCH cleaner then the sql stamntet. ...
    (microsoft.public.access.modulesdaovba)