There will be overhead on using TEMPORARY TABLE. Cursor is the best option.