Home page  
Help >
ddlGetCalc() - perform a CALC OBJECT
Version 7.11
ddlGetCalc() - perform a CALC OBJECT
ddlGetCalc() - perform a CALC OBJECT

Prototype:
   void ddlGetCalc(
      CONTROL *ctl,
      char *OptnStr,
      char *ArgList,           /* command argument list */
      char *DataImage);

Permitted values in OptnStr:
   /Knnn - in Direct Data mode (see below), nnn is the maximum number of 
         records to return in DataImage; default is 1;
   /P  - prints report via the print callback;

Form of ArgList:
       <cx> [<Table-Name>] { <RD-Name> | NULL } <Calc-Object-Name>
          <cx> is the target collection;
          <Table-Name> is the name of the table if the target collection
             is table-specific; if the target collection is the global collection, this parameter is null;
          <RD-Name> is the name of the RD to be used to copy data to
             the user's buffer; if there is no RD, this parameter is literal NULL;
          <Calc-Object-Name> is the name that was assigned to this object;

Description of DataImage:
DataImage is the user's buffer where results are to be stored. One image [virtual record] is delivered with each call to ddlGetCalc(). When ctl->Ans1 == 0, there are no more records.

Description:
ddlGetCalc() can be viewed as an extension to a global ddlGetRec().
1) It reads input from a raw or sorted table-specific collection;
   or from a joined global collection;
2) It processes each logical record according to the specified
   <Calc-Object-Name>;
3) It produces an intermediate or final result set in five 
   possible modes (non-exclusive):
   a) Delivered to the caller to the specified data buffer;
      this is Direct Data mode;
   b) Delivered formatted to the print callback;
      this is Print Output mode;
   c) It can produce a result collection by means of the SELECT
      statement; this is Collection mode;
   d) It can produce a scalar in a global variable;
      this is Scalar mode;
   e) It can write to a table with the WRITE statement; and/or
      it can update a table with the REWRITE statement;
 
The requirements for a non-null RD, a non-null DataImage buffer
and a PRINT command vary depending on the output mode:

   Mode          RD       DataBuff PRINT
   ----          --       -------- -----
   Direct Data   Req      Req      Req
   Print Output  NR       NR       Req
   Collection    NR       NR       NR
   Scalar        NR       NR       NR


In Direct Data mode (when both RD and DataBuff are non-null),
ddlGetCalc() returns with ctl->Ans1 == <number of records read>
after one or more record images have been transferred to DataImage; 
it returns with ctl->Ans1 == 0 when there are no more records. After
each return, ctl->Ans2 contains the current total of records returned.

In non-Direct Data mode (when either/both RD and DataBuff are 
null), ddlGetCalc() returns only after all input records have
been processed, and all output records (if any) have been 
returned. In this case, ctl->Ans1 == 0 and ctl->Ans2 is the
total number of records that have been returned by Print
Output mode.
 
Values returned in Control Structure:
Control.Ans1 (32 bit) Number of records returned (incremental)
Control.Ans2 (32 bit) Number of records printed
Control.Ans3 (32 bit) Number of records selected with CalcObject
SELECT Statement
Control.Ans1L (64 bit) Number of records returned (cumulative)
Control.Ans2L (64 bit) Number of records printed
(Duplicate of Control.Ans2)
Control.Ans3L (64 bit) Number of records selected with CalcObject
SELECT Statement
(Duplicate of Control.Ans3)
Control.Ans4L (64 bit) Number of records written with CalcObject
WRITE Statement
Control.Ans5L (64 bit) Number of records rewritten with CalcObject
REWRITE Statement
Control.Ans6L (64 bit) Number of records read

Copyright © 2019 , WhamTech, Inc.  All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. Names may be trademarks of their respective owners.