PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 14th, 2003, 03:42 PM
wolfespawn wolfespawn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 68 wolfespawn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via AIM to wolfespawn
java method to convert NON-ANSI ORACLE based queries to Postgres usable ANSI Queries?

i am faced with a decision of either a massive code overhaul or a nasty method/program to convert my Oracle based queries into a Oracle9i / Postgresql friendly manner.

the issue-

all my code was initially written against oracle7, oracle8i using sql queries that ran in these databases, for clients that used them. honestly, there is over a couple hundred thousand lines of code spread out through over 500+ java programs (using tags, with TLD's). a couple hundred of these tags/programs have the sql embedded with them. they have OUTER joins in them and based on ORACLE back then, it did not support the ANSI sql logic (using 'left outer join on'), so the outer join code is table.column(+)=table2.column.....

ORACLE is expensive, so alot of people want to use my code but want to use postgres as their database. i would like 1 set of code that could use either database, assuming the databases are set up exactly the same (already done). ORACLE9i now supports ANSI sql. So, I can go through the 500+ programs and change every single OUTER JOIN to ANSI sql, which could honestly take me months... also changing stuff like sequences (how they are called) and 'sysdate' to 'now()' and stuff like that....

OR - a java method that could take a NON-ANSI query and convert it to an ANSI QUERY and i could run the queries through this converter at runtime depending on the environment my client is running.

this way, all the code could be written as it always has been, and the converter could take care of all query changes.

the converter method is also preferential because if another difference is found that needs changed, it could be changed in the converter method 1 time, rather than the 500 programs, which have to be re-compiled and what not....

SO, my question is... has anyone heard of something like this method already existing?????

PLEASE RESPOND

thanks,
travis

Reply With Quote
  #2  
Old January 15th, 2003, 03:36 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 8,527 pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 1 Day 3 h 19 m 49 sec
Reputation Power: 537
DO NOT CROSSPOST!!! (here).
BTW, I don't know of a "sql translator", but I would suggest, in case you are forced to modify the application, to put really simple queries in it, and use views at the database level to prepare data.

Reply With Quote
  #3  
Old January 15th, 2003, 08:44 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
Unfortunately, I believe you are out of luck. I don't think I've ever heard of an "SQL converter" like that, nor do I think it would be a good idea even if you could find one. This would mean that every single query has to be run through an intermediary program, which will have to parse the query, rewrite it, and then send it to the database. I think it would be disastrous for performance. Much better just to dump all your SQL queries to text, and run a single Perl regex script to fix the syntax wherever it appears.

And pabloj is right. If you had followed the data independence principle from the start, then every one of your queries would be encapsulated in a view or stored procedure, making it quite easy to port your application to other database systems, simply by modifying your views or procedures. Generally, you should try not to have main SQL logic embedded in your application. Even where you do have it, it should be hidden in a class or module that can be modified without modifying the whole program.
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #4  
Old January 15th, 2003, 09:18 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 8,527 pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 1 Day 3 h 19 m 49 sec
Reputation Power: 537
SAPDB could be the solution

I've just noticed that SAPDB (free, opensource etc.) can run in Oracle 7 compatibility mode.
Check http://www.sapdb.org/sap_db_features.htm#SQL_Features and http://www.sapdb.org/htmhelp/3f/fa3...11/frameset.htm
Quote:
The SAP DB database system is capable of executing correct database applications and applications that are written in accordance with one of the following definitions:

INTERNAL (internal database system definition)
ANSI standard (ANSI X3.135-1992, entry SQL)
Definition DB2 Version 4
Definition ORACLE7
The database system is capable of checking new applications to ascertain whether they correspond to one of the above definitions. In particular, this means that no extensions that go beyond the selected definition are regarded as correct. However, support of other SQL modes is restricted with regard to DDL statements.

When you log on to the database system, you can enter one of the above definitions or SQL mode INTERNAL (default value).

Reply With Quote
  #5  
Old January 16th, 2003, 12:56 PM
wolfespawn wolfespawn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 68 wolfespawn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via AIM to wolfespawn
i guess i am confused as to how i would store my queries in some procedure because they are never the same... dynamic queries so to speak. (the WHERE clause is dependant upon user selections, which can be any of 600000 + different values...)
there are tables with over 600,000 records, and history tables that capture stuff on each of those rows (so about 4-6 times bigger). some of the SQL queries alone have more than 7-10 outer joins in each.

it is also impossible for us to write 'simple' queries because we are grabbing alot of data from many very large tables. i am not responsible for the start of this project, it is many years old and to redo the couple 100 thousand lines before me is not plausible right now...

yeah, i can see how converting the statements on the fly could have some performance issues, but there are down sides to either way... say, we decide to goto mySQL later or something.. then i have to go change every program AGAIN instead of just making another converter.

ill look into that link pab, looks like it is saying that oracle7 is ANSI compatible? if so, it would help with current code, thanks.

i really appreciate the replies. i would rather have an answer to my problem than a 'should of done....' on stuff i cant change from the past.

all the views and stuff make sense, but tell me if i am wrong. if i have a VIEW that goes against 3 tables, and the tables get updated, the VIEW doesnt update itself, does it? if not, a VIEW is not plausible for us for we need REAL time data, because the tables get updated CONSTANTLY and we cant be waiting to recreate or update the view all the time, because we have built views on these tables before and it took like 20 minutes to build... these arent small tables.

i am no DBA, i am a JAVA programmer trying to make the best of what i have... yep, a DBA would be nice, and so would alot of experience in databases, but i have what i know and these wonderful forums. so... if i am wrong in my ways of doing things, please reply with a better plausible way.

Reply With Quote
  #6  
Old January 17th, 2003, 03:42 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 8,527 pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 1 Day 3 h 19 m 49 sec
Reputation Power: 537
Hi, you wrote:
Quote:
looks like it is saying that oracle7 is ANSI compatible?

No, it says that SAPDB can work with Oracle 7 or ANSI SQL syntax.

Quote:
if i have a VIEW that goes against 3 tables, and the tables get updated, the VIEW doesnt update itself,...

Yes it does (even a snapshot/materialized vew on Oracle).

Quote:
i am confused as to how i would store my queries in some procedure because they are never the same... dynamic queries so to speak

You should search www.databasejounal.com or Google for "dynamic PL/SQL" (for Oracle) but it's similar for SQLServer, PostgreSQL or other dbs (not MySQL).

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > java method to convert NON-ANSI ORACLE based queries to Postgres usable ANSI Queries?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap