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();

0 comments:

Post a Comment

Total Pageviews

Copyright © Tech & Management Notes