im writing a stored procedure, trying to avoid the use of a cursor but cant think of a work around. here is a sample example of my case.
i have tables : customers and orders
first i query the orders for any lines with due quantity grouped by the customer id into a cursor.
then i loop the cursor and select all due orders for each customer into a second cursor which i loop in turn to create a html file in a specific format which i then email through.

i couldnt come with a more efficient structure, any suggestions ??
thanks