Home » SQL & PL/SQL » SQL & PL/SQL » Any parser for SQL to read and write in java
Any parser for SQL to read and write in java [message #446587] Tue, 09 March 2010 07:37 Go to next message
manjukmoorthi
Messages: 20
Registered: February 2010
Junior Member
Hello,

I want to know if there are any freeware's available to read and write .sql files. I hava a .sql file with set of insert statements and I need to identify the values that are pushed into table, the table name, the inner query clauses etc., from the sql statement.

After identifying, need to translate and push those changes back to the .sql file. Is there any way to do this with help of parsers rather reading the whole of file line by line.

I did come across few parsers like ZQL, sqljep etc., but could not really solve the issue. Please help..
Thanks in advance.

Re: Any parser for SQL to read and write in java [message #446590 is a reply to message #446587] Tue, 09 March 2010 08:14 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Is there any way to do this with help of parsers rather reading the whole of file line by line.

You mean read yourself, because the parser will read the sql file line by line.

There is no such tool as far as I know.
What do you want to do with the parse file?

Regards
Michel
Re: Any parser for SQL to read and write in java [message #446682 is a reply to message #446587] Tue, 09 March 2010 23:20 Go to previous messageGo to next message
manjukmoorthi
Messages: 20
Registered: February 2010
Junior Member
Say I have a line like below,
INSERT INTO soms_user_settings 
           (user_id, 
            module_id, 
            section_id, 
            key_id, 
            value_id, 
            DESCRIPTION, 
            preference_list, 
            preference_type, 
            default_value, 
            preference_list_local, 
            default_value_local) 
SELECT DISTINCT 'LANGUAGE', 
                'L', 
                'system_preferences', 
                'ATASSht', 
                'Action Statement Sheet', 
                'LCO Tracking label for printing Action Statement Sheet', 
                NULL, 
                9, 
                'Action Statement Sheet', 
                NULL, 
                NULL 
FROM   dual 
WHERE  NOT EXISTS (SELECT * 
                   FROM   soms_user_settings 
                   WHERE  user_id = 'LANGUAGE' 
                          AND module_id = 'L' 
                          AND section_id = 'system_preferences' 
                          AND key_id = 'ATASSht'); 


These statements gets repeated in the file consecutively. I need to get the insert column values (like user_id, module_id etc.,) and values that are inserted into the table (like 'LANGUAGE', 'L','system_preferences' etc., ) into any data structure. And also replace the values with translated values in same positions in writing back the values.
Re: Any parser for SQL to read and write in java [message #446689 is a reply to message #446682] Wed, 10 March 2010 00:23 Go to previous message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I think you have to create your own parser.
If the purpose is just this, it is not very difficult to create one using lex and yacc on Unix. I have created a parser for SELECT (which is far more complex) using these tools (more than 15 years ago).
It was in C but I think there would exist the same tools in Java now.

Regards
Michel
Previous Topic: Scheduling a stored procedure/package
Next Topic: Converting HTML format text to Plain Text
Goto Forum:
  


Current Time: Thu Sep 29 00:31:04 CDT 2016

Total time taken to generate the page: 0.15215 seconds