0

What is the syntax to run a straight sql statement in a progress application?

  SELECT count(distinct myField2) FROM myTable WHERE myField = myVariable);

I've figured out how to do this with a for each but I would still like to run this command. Using a for each:

def var iTmpCount as int no-undo.
for each myTable no-lock where myField = myVariable break by myField2:
  if first-of (myTable.myField2) then 
    iTmpCount = iTmpCount + 1.
end. 
Bill
  • 1,237
  • 4
  • 21
  • 44
  • What you're looking for is called an aggregate. IIRC look into the `ACCUMULATE` function. Either that or upgrade to using SQL with the JDBC/ODBC drivers. :-) – Abe Voelker Oct 24 '12 at 14:53

1 Answers1

2

The 4GL has an ancient and deprecated implementation of SQL-89.

You can do some simple things successfully. It is sometimes helpful for an ad-hoc query.

The documentation is limited and, since it is a deprecated feature, it will never be improved or enhanced.

The 4GL is not a SQL tool and the embedded SQL support should not be used. Don't try to apply SQL thinking to 4GL, you will only regret it.

SQL-92 is supported via the ODBC & JDBC drivers. But that is outside the 4GL.

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33