• For same purpose we can use cussor too.

    Can you specify which idea is better and why ?

    Cursor Or UDF.