Search This Blog

Tuesday, December 29, 2009

SQL Definitions and the SQL Class Example

Can you spot any best practices in the piece of code below?

We can use the SQL class to create temporary SQL statements for manipulating data. The following example creates a temporary SQL statement, then writes all the rows of data from a record to a file:

Local Record &LN;

Local File &MYFILE;

Local SQL &SQL2;

&MYFILE = GetFile("record.txt", "A");

If &MYFILE.IsOpen Then

If &MYFILE.SetFileLayout(FILELAYOUT.ABS_HIST) Then

&LN = CreateRecord(RECORD.ABSENCE_HIST);

&SQL2 = CreateSQL("%Selectall(:1)", &LN);

While
&SQL2.Fetch(&LN)

&MYFILE.WriteRecord(&LN);

End-While;

End-If;

End-If;

&MYFILE.Close();

No comments:

Post a Comment

Building Scalable Systems - Handling Hyper-Growth

Hyper-growth is one of the most exhilarating phases for any business, marked by rapid expansion, new opportunities, and an undeniable sense ...