Solved

Help - what's wrong with this query

Posted on 1998-11-18
5
120 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
ID: 1347270
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
ID: 1347271
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
ID: 1347272
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
ID: 1347273
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
ID: 1347274
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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