Creating a dynamic SQL statement
Posted by: fiona healy
Date: February 15, 2005 03:06PM

Hey everyone,

im creating an system that sits on a MySQL DB and querys the Data in it in order to generate reports.

My GUI allows users to create report definitions specifying name description etc.

What i have as of now is a Reporting application system with a MyDQL DB of its own that should be able to sit on top of another MySQL DB and produce reports on the data held in it.

So if you can imagine that a user logs into the system and is presented with a wizard whereby they can specify a reports name, description, blah-de-blah as well as other attributes including field names that exist in this underlying database.

When the user is finished defining their report, the report is supposed to be generated using a dynamic SQL statement consisting of the field names they specified... and this is where im stuck.

How can i take these field names that the user has specified and construct a SQL query without them knowing about how tables are related in DB etc.

what i was initially thinking i could do was hold all column names and associated tablenames in my application's database...because i will need these to load the GUI in the first place so that the user can select existing DB fields...but I know now that this wont work either because ill need to specify joins between tables as well in my query.

Please help!
I need the quickest and easiest solution possible as i am under serious time pressure

Options: ReplyQuote

Written By
Creating a dynamic SQL statement
February 15, 2005 03:06PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.