Solved

How do I write a CASE statement in BDE Local SQL

Posted on 2008-06-11
6
1,411 Views
Last Modified: 2013-11-23
Hi Team,

I'm trying to get Database Tour to run a CASE statement like

Case GROUPCODE
WHEN sum(invdtl.linetot) = 0 then '"G0"
WHEN sum(invdtl.linetot) between 1 and 1000 then '"G999"
WHEN sum(invdtl.linetot) between 1000 and 2000 then '"G1999"

End Case as 'GROUPCODE'

I get an error saying

"Invalid use of Keyword
Token: CASE"

I gather "CASE" is not supported in the BDE implementation of local SQL

How should I write this now?

 Cheers
bernard

 
0
Comment
Question by:BernardGBailey
[X]
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
  • 3
  • 2
6 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 500 total points
ID: 21765054
You are correct - CASE is not supported by BDE Local SQL.
If you go into your BDE directory (usually at C:\Program Files\Common Files\Borland Shared\BDE you will see a file called LOCALSQL.HLP. If you open it and go to Index -> Unsupported Language it lists "CASE" as unsupported
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 21765063
My advice is to just execute multiple queries according to what you're trying to do.
So do one query, get the result, then in delphi say
if between 0 and 1000 then G999. etc
then build another query using a parameter, and insert G999 into the parameter
0
 

Author Comment

by:BernardGBailey
ID: 21765088
Would a subselect work just as well or is that not supported either?
0
Industry Leaders: 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!

 
LVL 13

Expert Comment

by:rfwoolf
ID: 21765133
Hmmm. . i think it is supported in some ways...
Using the help file I told you about, looking up "SubQueries" you can use
the IN predicate
the EXISTS predicate
and it also mentions the SOME/ANY/ALL predicates
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 21766186
There is still the possibilty of installing a database on your local computer.
Like the MSSQL Desktop Engine, Oracle10G, Interbase, ...

Most of the databases can be run locally, you would then have the full power of a rdbms system at your disposal.

if it's an older computer the 2000 MSDE for example
http://www.microsoft.com/downloads/details.aspx?familyid=413744D1-A0BC-479F-BAFA-E4B278EB9147&displaylang=en
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 21863338
anyway you have an incorrect syntax in your case too ...

Case
  WHEN sum(invdtl.linetot) = 0 then '"G0"
  WHEN sum(invdtl.linetot) between 1 and 1000 then '"G999"
  WHEN sum(invdtl.linetot) between 1000 and 2000 then '"G1999"
ELSE
  NULL
End Case as 'GROUPCODE'

Removed GROUPCODE from the top
you don't have an ELSE section (not necessary but then this is what you get)
0

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…

730 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