次のコードは、演習 3 で完成したバージョンの selectItems.egl ファイルです。このファイル内にエラーがある場合 (赤の X 記号でマークされます) は、作成したコードがこのコードと一致していることを確認してください。
package programs;
import eglderbyr7.data.Item;
import eglderbyr7.primitivetypes.data.Price;
program selectItems type BasicProgram {}
function main()
try
printExpensiveItems(200);
onException(exception SQLException)
handleDBException(exception);
end
end
function printExpensiveItems(maxPrice Price in)
tempItem Item;
open expensiveItems for tempItem with
#sql{
select
EGL.ITEM.ITEM_ID, EGL.ITEM.NAME, EGL.ITEM.IMAGE,
EGL.ITEM.PRICE, EGL.ITEM.DESCRIPTION
from EGL.ITEM
where
EGL.ITEM.PRICE >= :maxPrice
order by
EGL.ITEM.ITEM_ID asc
};
forEach (tempItem)
SysLib.writeStdout(tempItem.Name :: " " ::
tempItem.Description :: " $" :: tempItem.Price);
end
end
function handleDBException(exception SQLException)
SysLib.writeStdout("Error accessing database. "::
"See Troubleshooting section");
SysLib.writeStdout(exception.message);
end
end