Use the following process guidelines for implementing the Initiate, Execute, and Terminate functions for a sequential producer operator.
Implementing a Sequential Producer Operator
Function |
Process |
Initiate |
- Use the Get Attribute function to get the path name of the sequential file.
- Use the path name to open the file and get the file handle.
- Use the Allocate Storage function to allocate a user area.
- Save the file handle in the user area.
- Use the Allocate Storage function to allocate a data buffer area big enough to hold the maximum size of a row in the sequential file.
- Save the data buffer address and the buffer length in the user area.
- Use the Put Attribute function to save the user area.
|
Execute |
- Get the output table handle.
- Use the Get Attribute function to get the user area.
- Get the file handle and the data buffer address from the user area.
- Use the file handle to read the next row into the data buffer.
- Use the Get Table Schema List function to get the output data schema.
- If the read is successful, use the Put Row function to write the row to the output data stream and return the PXSTC_SamePhase status.
- If the read/write is not successful, return bad status.
- If end-of-file is encountered, return either PXSTC_EndOfData or PXSTC_EndMethod status.
|
Terminate |
- Use the Get Attribute function to get the user area.
- Get the file handle from the user area.
- Use the file handle to close the sequential file.
- Use the Free Storage function to free the data buffer.
- Use the Free Storage function to free the user area.
|