Solved

Help - what's wrong with this query

Posted on 1998-11-18
5
118 Views
Last Modified: 2010-04-04
I keep all sorts of EDB errors when running the following query and I'm at my wits end. Can anyone see or suggest what might be wrong. All I want to do is get the total of the Value field in the orders table. Thanks.

with Query1 do begin
     Close;
     with SQL do begin
       Clear;
       Add ('SELECT Sum (Value) FROM Orders');
       end;
     Open;
     end;
0
Comment
Question by:cavalry
5 Comments
 
LVL 7

Expert Comment

by:BlackMan
Comment Utility
The only thing is the use of nested With. Especially in D4, I've seen a few examples where methods are not called in the context of the With, one are counting on. This is of course only true if the method is declared in both of the objects in With statements..
Try to do the same thing without the use of With, the SQL look ok..
One other thing could be if you are tryingto close an query that is not active, I'm not quite sure if that is supported. Otherwise, use If Active Then Close
0
 
LVL 3

Expert Comment

by:Matvey
Comment Utility
Try running the query in the Database Desktop. If you get no errors there, then try to be more specific with the error messages you get while running this from your code.
0
 

Author Comment

by:cavalry
Comment Utility
I think Ive got it sorted now, BUT HOW do I show the result of the Sum calculation in a DBText component ??

Thanks
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 20 total points
Comment Utility
cavalry you can use :

select Sum(Value) as SumOfValue from orders

Now sumOfValue is a fieldname. Can be used as normal fieldname.

Zif.
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
hi cavalry,

is the dbtext.field connected to a datasource which is pointed to your query, the fieldname is the name of your aggregat-function (in this case SUM(VALUE)).

But the better way is zifs answer

meikl
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

13 Experts available now in Live!

Get 1:1 Help Now