but could anyone tell me how to get the whole sql statement which the exception occurred?
Unfortunately (what a shame ...), not in DB2 for LUW.
There is no item like DB2_ROW_NUMBER in the GET DIAGNOSTICS statement in DB2/i or DB2/z where you can get the row number of your SP where you got an error.
Only since DB2 10.1.2 you have such ability, but it's implemented differently: FP2: Error locating in SQLCA expanded
You are still not able to get this value in some SQL/PL variable of calling SP, for examle, since we don't have an ability to access these SQLCA fields in SQL/PL.