Programming model

AEs are invoked from traditional SQL functions that require defined input and output parameters. When invoked from scalar or table functions, AEs deviate from the traditional database programming model and can use a model of programming that operates in the manner of File I/O to access the NPS system data stream. The data stream consists of multiple rows containing one or more columns. Metaphorically, the rows are like records in a file. In a loop, the AE reads input rows, performs application-specific processing, and writes output rows.

When writing an AE, the structure is similar to file semantics:
initializeAE();
while (moreData) {
getNextRecord();
doSomething();
maybeOutputResults();
}
maybeOutputResults();
done();
The approach is to mimic the file i/o pseudo-code:
openFile();
while (notEOF) {
getNextLine();
doSomething();
maybeWriteOutput();
}
maybeWriteOutput();
closeFile();