Kbase P123394: How to assign the sum of a table column into a variable using SQL-89 and 4GL?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  13/04/2007 |
|
Status: Unverified
GOAL:
How to assign the sum of a table column into a variable using SQL-89 and 4GL?
GOAL:
What is the syntax for the SQL-89 SELECT INTO statement?
FACT(s) (Environment):
Progress 8.x
Progress 9.x
FIX:
The following code shows the syntax of the SQL-89 SELECT INTO statement, (SELECT SUM(balance) INTO dTotal FROM Customer.), and how to use it to assign the sum of a table column into a variable using SQL-89 and 4GL:
DEFINE VARIABLE dTotal AS DECIMAL NO-UNDO.
SELECT SUM(balance) INTO dTotal FROM Customer.
MESSAGE dTotal
VIEW-AS ALERT-BOX INFO BUTTONS OK.
The following pure 4GL code is functionally equivalent to the above SQL-89 code:
DEFINE VARIABLE dTotal AS DECIMAL NO-UNDO.
FOR EACH Customer NO-LOCK:
dTotal = dTotal + Balance.
END.
MESSAGE dTotal
VIEW-AS ALERT-BOX INFO BUTTONS OK.