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
Return to Lesson 3: Managing a cursor with open and forEach.