Android Question Cursor as Parameter

Discussion in 'Android Questions' started by Rob Bliss, Mar 22, 2019.

  1. Rob Bliss

    Rob Bliss Member Licensed User

    When passing a cursor as a parameter, when is the correct time(s) to close the cursor?

    Code:
    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
     
  2. MarkusR

    MarkusR Well-Known Member Licensed User

    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:
    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
    DonManfred and Peter Simpson like this.
  3. mc73

    mc73 Well-Known Member Licensed User

    What is func really supposed to do?
     
  4. Rob Bliss

    Rob Bliss Member Licensed User

    Could be anything, was just an example
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice