Progress > SQL

Peter Szasz

New Member
It's my problem as well, and my specific question is, how to use an SQL statement in Progress. I'm getting nowhere using FOR EACH because I can't use DISTINCT, GROUP BY or HAVING keywords. For example I'd like to add the result set of a query to the list items of a combo box, but I need DISTINCT and FOR EACH doesn't make it possible.
Peter
 
Peter,

You should be able to do almost anything in Progress that you can do in SQL. SQL will do some things better, Progress others.

The keywords do not exist in the 4GL because it has a different syntax, but you should be able to implement the concepts.

It is not just a different language though, it is a different type of language, row-oriented as opposed to set-oriented, and it is difficult for any programmer to make the transition from one to the other.

I've never done anything non-trivial with SQL, but to manipulate groups you use the BREAK BY clause on the FOR EACH statement, then catch the group change using FIRST-OF/LAST-OF.

For more advanced processing, you can use Temp-Tables.

Here's a SELECT DISTINCT example:

KB P85531
Title: "How to implement a SELECT DISTINCT In Progress 4GL."
http://tinyurl.com/axfu4


KB P18984
Title: "How to populate a COMBO-BOX widget with two database fields?"

http://tinyurl.com/9kv5q


If you are going to be using Progress quite a lot, it will be worth experimenting with FOR EACH (see the Help reference for full syntax) to see its power. Remember, if you can do it in SQL, you can do it in the 4GL, but you will probably need to think laterally until you get the hang of it. If you get stuck, phrase your query request in English (not many SQL experts here), using the Sports database, and no doubt someone will be able to help you.

Also try:

http://www.peg.com/lists/sql92/web/index.html

for more advanced SQL stuff.


If they are translations from English, please post FOR EACH help requests in the main Development forums here or the Peg for a quicker response.


HTH

Lee
 
Top