Description:-
A select statement can be written specifically to return only one record or to return many records. If we expect the select statement to return multiple records and we would like to loop through these records, we simply embed the select statement within a while loop.
The following examples will demonstrate how to write
simple select statements that return different data from
the same table.
The first example will select all columns from all records in the Cartable:
CustTable
The following list shows the test data for the CustTable:
The first example will select all columns from all records in the Cartable:
CustTable
The following list shows the test data for the CustTable:
AccountNum
|
Name
|
CustGroup
|
Blocked
|
1101
|
Forest Wholesales
|
10
|
No
|
1102
|
Sunset Wholesales
|
20
|
No
|
1103
|
Cave Wholesales
|
10
|
No
|
1104
|
Desert Wholesales
|
30
|
Yes
|
Code:-
static void selectAllRecordsStatic(Args _args) { A_PurchaseOrder objA_PurchaseOrder; int records; info("------------------START-------------------"); while select objA_PurchaseOrder { info("--------------NEW RECORD--------------"); info (strfmt("CarId: %1", objA_PurchaseOrder.Purchase_ID)); info (strfmt("CarBrand: %1", objA_PurchaseOrder.Vender_Code)); info (strfmt("Model: %1", objA_PurchaseOrder.Purchase_Date)); info (strfmt("ModelYear: %1", objA_PurchaseOrder.Status)); info (strfmt("Mileage: %1", objA_PurchaseOrder.Purchase_Amount)); records++; } info("------------------END-------------------"); info(strfmt("%1 records was selected", records)); }
Output:-
Thanks for comments.....