Examples: FetchBatchSize property

This example shows an action (the Click sub) that displays the current CacheLimit and FetchBatchSize values, sets new ones according to user input, and displays the new values. The example makes sure that FetchBatchSize is not greater than CacheLimit.

Uselsx "*LSXODBC"
%INCLUDE "lsconst.lss"

Dim con As ODBCConnection
Dim qry As ODBCQuery
Dim result As ODBCResultSet

Sub Postopen(Source As Notesuidocument)
  Set con = New ODBCConnection
  Set qry = New ODBCQuery
  Set result = New ODBCResultSet
  Set qry.Connection = con
  Set result.Query = qry
  con.ConnectTo("ATDB")
  qry.SQL = "SELECT * FROM STUDENTS ORDER BY LASTNAME"
  result.Execute
  ...
End Sub
Sub Click(Source As Button)
  If Messagebox("Current settings" & Chr(10) & Chr(10) _
  & "Cache limit: " & result.CacheLimit & Chr(10) _
  & "Fetch batch size: " & result.FetchBatchSize, _
  MB_YESNO, "Do you want change?") = IDYES Then
    cLimit = Inputbox _
    ("Enter 0 for DB_NONE or size of cache", _
    "Cache limit?")
    If cLimit = 0 Then
      result.cacheLimit = DB_NONE
    Elseif cLimit > 0 Then
      result.cacheLimit = cLimit
    Else
      Messagebox  _
      "Cache limit must be 0 or positive integer"
      Exit Sub
    End If
    fbSize = Inputbox("Enter fetch batch size", _
      "Fetch batch size")
    If fbSize < 1 Then
      Messagebox _
      "Fetch batch size must be positive integer 
      and not zero"
      result.FetchBatchSize = 1
    Elseif cLimit <> 0 And fbSize > cLimit Then
      result.FetchBatchSize = cLimit
      Messagebox "Fetch batch size reduced to" _
      & result.CacheLimit,, _
      "Fetch batch size cannot exceed cache limit"
    Else
      result.FetchBatchSize = fbSize
    End If
    Messagebox "New settings" & Chr(10) & Chr(10) _
    & "Cache limit: " & result.CacheLimit & Chr(10) _
    & "Fetch batch size: " & result.FetchBatchSize, , _
    "New settings"
  End If
End Sub
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
  result.Close(DB_CLOSE)
  con.Disconnect
End Sub