Solved

Can MIDAS strcture support dynamically generated SQL

Posted on 1998-10-16
7
241 Views
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?
0
Comment
Question by:dwwang
7 Comments
 
LVL 12

Expert Comment

by:rwilson032697
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).
0
 
LVL 4

Author Comment

by:dwwang
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.
0
 
LVL 1

Accepted Solution

by:
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;

var
  qry: TQuery;

begin
  qry := TQuery.Create(Application);
  qry.DatabaseName := 'mydb';
  qry.SQL.Add(SQL);
  result := qry.Provider;
end;

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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Author Comment

by:dwwang
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 ?
0
 
LVL 1

Expert Comment

by:ghjm
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');
0
 
LVL 4

Author Comment

by:dwwang
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.
0
 

Expert Comment

by:karthi_v
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,
Karthi
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now