Rob Bliss Member Licensed User Longtime User Mar 22, 2019 #1 When passing a cursor as a parameter, when is the correct time(s) to close the cursor? Code: Copy Sub main Dim v_Cursor as Cursor = SQL.ExecQuery("SELECT * FROM TABLE") func(v_Cursor) v_Cursor.Close '? End Sub Sub func(p_Cursor as Cursor) p_Cursor.getString("column") p_Cursor.Close '? End Sub Cheers
When passing a cursor as a parameter, when is the correct time(s) to close the cursor? Code: Copy Sub main Dim v_Cursor as Cursor = SQL.ExecQuery("SELECT * FROM TABLE") func(v_Cursor) v_Cursor.Close '? End Sub Sub func(p_Cursor as Cursor) p_Cursor.getString("column") p_Cursor.Close '? End Sub Cheers
MarkusR Well-Known Member Licensed User Longtime User Mar 22, 2019 #2 i would close it where u open it, in the same sub. its easier to understand. just think about if you need this. if u would close it in "func" u can't use "func" again. Code: Copy Sub main Dim v_Cursor as Cursor = SQL.ExecQuery("SELECT * FROM TABLE") func(v_Cursor) func(v_Cursor) v_Cursor.Close End Sub Last edited: Mar 22, 2019 Upvote 0
i would close it where u open it, in the same sub. its easier to understand. just think about if you need this. if u would close it in "func" u can't use "func" again. Code: Copy Sub main Dim v_Cursor as Cursor = SQL.ExecQuery("SELECT * FROM TABLE") func(v_Cursor) func(v_Cursor) v_Cursor.Close End Sub
mc73 Well-Known Member Licensed User Longtime User Mar 23, 2019 #3 What is func really supposed to do? Upvote 0
Rob Bliss Member Licensed User Longtime User Mar 25, 2019 #4 mc73 said: What is func really supposed to do? Click to expand... Could be anything, was just an example Upvote 0
mc73 said: What is func really supposed to do? Click to expand... Could be anything, was just an example