Can MIDAS strcture support dynamically generated SQL

Posted on 1998-10-16
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
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 100 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.
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.


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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 167
Delphi XE10, MySQL Query 4 167
Run video youtube webbrowse 10 65
DBCtrlGrid, Delphi, Scroll 8 38
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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