이 코드는 학습 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
학습 3: open 및 forEach로 커서 관리로 되돌아가십시오.