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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


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

Independent Software Vendors: 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!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 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