Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2010
    Location
    Sydney
    Posts
    15

    Unanswered: SQL With PL/SQL parser

    Hi there,

    I am looking for a solid PL/SQL and SQL statement parser written in Java.

    What I really need is a java Utility class to extract a multilined query

    eg

    /* SQL */
    create table blah(blah blah blah);

    select * from blah;

    desc blah;

    /* PLSQL here */
    create or replace
    package atuTransaction
    as
    v_version varchar2(20) := 'Version 0.23';

    function 021Exists(p_511_ide varchar2) return boolean;
    procedure updateInt013Balval(p_trn511_trcseq varchar2,
    p_accide varchar2,
    p_invopt varchar2,
    p_balval varchar2);

    end atuTransaction;

    /* SQL */
    select * from blah;

    --------------

    And be able to segment the entire multilined query so that it produces an Array of Java Executable SQL Statements.
    [0] = create table blah(blah blah blah);
    [1] = select * from blah;
    [2] = desc blah;
    [3] = create or replace package atuTransaction as v_version varchar2(20) := 'Version 0.23'; function 021Exists(p_511_ide varchar2) return boolean; procedure updateInt013Balval(p_trn511_trcseq varchar2, p_accide varchar2, p_invopt varchar2, p_balval varchar2);
    [4] = select * from blah;


    I am sure that this has been done before in tools like SQL Developer/Plus etc, but I was wondering if there was any library available I could just use quickly?

    Cheers,
    Al_RelEZ_Al

  2. #2
    Join Date
    Aug 2010
    Posts
    1
    General SQL Parser is what you need, check this article:
    Separate the SQL Commands in a SQL script

  3. #3
    Join Date
    Aug 2010
    Location
    Sydney
    Posts
    15

    interesting

    Thanks dpriver


    Hhhhmm...

    Interesting. Though I don't know if I could afford the license if it is on a per year basis.

    Sure there isn't anything open source available out there? I would have thought that since SQL2008 has been around for so long as is parsing etc, this would be a done and dusted task.

    Either way I'll have a look at General SQL

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    PostgreSQL: The world's most advanced open source database

    open source DB with PL/SQL like language
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Aug 2010
    Location
    Sydney
    Posts
    15

    uhhh

    thanks anacedent,

    Postgres is a great Database...

    But that's not particularly helpful.

    I'm looking for a parser at this stage...

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >I'm looking for a parser at this stage...
    doesn't Postgres contain a SQL & PL/SQL parser?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by anacedent View Post
    >I'm looking for a parser at this stage...
    doesn't Postgres contain a SQL & PL/SQL parser?
    It sure does, but not for Oracle SQL and not for Oracle PL/SQL.

    Although they are pretty close, the Postgres parser needs to be changed heavily to accept the complete Oracle syntax.

  8. #8
    Join Date
    Aug 2010
    Location
    Sydney
    Posts
    15

    interesting

    Interesting...

    So PgSQL has a Java library that does SQL2008 and some of PL/SQL?

  9. #9
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by Al_RelEZ_Al View Post
    So PgSQL has a Java library that does SQL2008 and some of PL/SQL?
    No, it has not.

    Postgres has a C (C++) based SQL parser.
    As the Postgres syntax is - to some extent - similar to Oracle's that could be used as base for your own development. I think that's what anacedent was suggesting

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •