Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Can MIDAS strcture support dynamically generated SQL

Posted on 1998-10-16
Medium Priority
Last Modified: 2010-04-06
I would like to use MIDAS structure, but our query SQL is generated at runtime, and I can't find whether client/provider can support that.

Could any one tell me? If it cannot support, who can give me some suggestion on how to do that using Multi-tier structure?
Question by:dwwang
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 1343183
The TQuery object lets you use any run-time generated SQL statement supported by the database you are connected to. You just construct a string containing the SQL statement and add it to the SQL property (a string list).

Author Comment

ID: 1343184
Sorry, I'm talking about using MIDAS architecture, for which one can only use TClientDataset/TProvider, and the SQL statements can only be staored in the query at server-side, which is not controlled by client programm. What I want to do is to using dynamic generated SQL in the client programme.

Accepted Solution

ghjm earned 200 total points
ID: 1343185
Well, I haven't actually tried it, but I'd try something like this (as a method of your remote datamodule on the server side):

function CreateNewQuery(const SQL: string): TProvider;

  qry: TQuery;

  qry := TQuery.Create(Application);
  qry.DatabaseName := 'mydb';
  result := qry.Provider;

Export this in your type library, then call it and assign the result to the Data property of a ClientDataSet. Ought to work. You might have to hack a bit. And I'm not sure how you would handle the problem of disposing the query objects once you were finished with them. But it's a start, anyway.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 1343186
Sorry, but where should I put and how can I call this function? At server side, how can I call it from client side? At client side, is there any use since the provider is also at client side ?

Expert Comment

ID: 1343187
You would implement this function as a method of the data module on the server side. Then, on the client side, you would do something like:

ClientDataSet1.Data := DCOMConnection1.AppServer.NewQuery('select * from mytable');

Author Comment

ID: 1343188
Thanks, I don't know D4 already had such kind of capability, I will have a try ASAP, and of course accept the answer after that.

Expert Comment

ID: 2866505
Hi Dwwang,

to pass the sql statment from client side you can use TClientDataset.DataRequest(sql statement) method. The parameter is an OLE Varient. so you can pass the SQL stament (type string).

with regards,

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question