Difference between revisions of "CursorAdapter"

From Lianjapedia
Jump to: navigation, search
(Methods)
 
(26 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
This class supports the [[:Category:Common_Properties|Common Properties]] plus the following:
 
This class supports the [[:Category:Common_Properties|Common Properties]] plus the following:
  
{| class="wikitable" width=100%
+
{| class="wikitable" width="100%"
 
!width="20%"|Property
 
!width="20%"|Property
 
!Access (R/RW)
 
!Access (R/RW)
Line 11: Line 11:
 
!width="50%"|Description
 
!width="50%"|Description
 
|-
 
|-
|valign="top"|DataSourceType
+
|Alias
 +
|RW
 +
|Character
 +
|Alias name
 +
|-
 +
|valign="top"|AllowDelete
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether delete operations are allowed
 +
|-
 +
|valign="top"|AllowInsert
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether insert operations are allowed
 +
|-
 +
|valign="top"|AllowSimultaneousFetch
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether simultaneous fetch operations are allowed
 +
|-
 +
|valign="top"|AllowUpdate
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether update operations are allowed
 +
|-
 +
|valign="top"|AutoSync
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether cursor is refreshed automatically when you insert, delete or update records so that the local cursor and the remote data source are kept in sync, but still on the same row as before the INSERT, DELETE or UPDATE operation.
 +
|-
 +
|valign="top"|BatchUpdateCount
 +
|valign="top"|RW
 +
|valign="top"|Numeric
 +
|valign="top"|Number of update statements sent
 +
|-
 +
|valign="top"|BreakOnError
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether errors break program execution
 +
|-
 +
|valign="top"|CompareMemo
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether memos are included in where update clauses
 +
|-
 +
|valign="top"|ConversionFunc
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|Type of the DataSource: "" (native) or "ODBC"
+
|valign="top"|Comma-separated list of field and function name pairs
 +
|-
 +
|valign="top"|CursorSchema
 +
|valign="top"|RW
 +
|valign="top"|Character
 +
|valign="top"|Structure of the cursor
 +
|-
 +
|Database
 +
|RW
 +
|Character
 +
|Database name
 
|-
 
|-
 
|DataSource
 
|DataSource
Line 21: Line 76:
 
|Source of data
 
|Source of data
 
|-
 
|-
|valign="top"|DataSourceUsername
+
|valign="top"|DataSourceHost
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|Username for DataSource
+
|valign="top"|Hostname or IP for DataSource
 +
|-
 +
|valign="top"|DataSourceOptions
 +
|valign="top"|RW
 +
|valign="top"|Character
 +
|valign="top"|Options string for DataSource
 
|-
 
|-
 
|valign="top"|DataSourcePassword
 
|valign="top"|DataSourcePassword
Line 31: Line 91:
 
|valign="top"|Password for DataSource
 
|valign="top"|Password for DataSource
 
|-
 
|-
|valign="top"|DataSourceOptions
+
|valign="top"|DataSourcePort
 +
|valign="top"|RW
 +
|valign="top"|Numeric
 +
|valign="top"|Port number for DataSource
 +
|-
 +
|valign="top"|DataSourceType
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|Options string for DataSource
+
|valign="top"|Type of the DataSource: "LOCAL" or "ODBC"
 
|-
 
|-
|valign="top"|DataSourceHost
+
|valign="top"|DataSourceUsername
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|Hostname or IP for DataSource
+
|valign="top"|Username for DataSource
 
|-
 
|-
|valign="top"|DataSourcePort
+
|valign="top"|Dbtype
 +
|valign="top"|R
 +
|valign="top"|Character
 +
|valign="top"|Database type, e.g. "MYSQL", "MSSQL"
 +
|-
 +
|DeleteCmd
 +
|RW
 +
|Character
 +
|Delete command string
 +
|-
 +
|valign="top"|FetchAsNeeded
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether records are fetched as needed
 +
|-
 +
|valign="top"|FetchSize
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Numeric
 
|valign="top"|Numeric
|valign="top"|Port number for DataSource
+
|valign="top"|Number of rows fetched
 
|-
 
|-
|Alias
+
|valign="top"|Flags
 +
|valign="top"|RW
 +
|valign="top"|Numeric
 +
|valign="top"|Flag settings
 +
|-
 +
|InsertCmd
 
|RW
 
|RW
 
|Character
 
|Character
|Alias name
+
|Insert command string
 
|-
 
|-
|valign="top"|
+
|valign="top"|KeyFieldList
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|
+
|valign="top"|Comma-separated list of primary fields
 
|-
 
|-
|valign="top"|
+
|valign="top"|MaxRecords
 
|valign="top"|RW
 
|valign="top"|RW
|valign="top"|Character
+
|valign="top"|Numeric
|valign="top"|
+
|valign="top"|Maximum number of rows returned
 
|-
 
|-
|valign="top"|
+
|valign="top"|NoData
 
|valign="top"|RW
 
|valign="top"|RW
|valign="top"|Character
+
|valign="top"|Boolean
|valign="top"|
+
|valign="top"|Whether cursoradapter should return no data
 
|-
 
|-
|valign="top"|
+
|valign="top"|Prepared
 
|valign="top"|RW
 
|valign="top"|RW
|valign="top"|Character
+
|valign="top"|Boolean
|valign="top"|
+
|valign="top"|Whether to prepare SQL statements for subsequent requery
 
|-
 
|-
|valign="top"|
+
|valign="top"|QuoteString
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|
+
|valign="top"|Replacement string for single quote characters
 +
|-
 +
|SelectCmd
 +
|RW
 +
|Character
 +
|Select command string
 
|-
 
|-
|valign="top"|
+
|valign="top"|SendUpdates
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether to send an update query
 +
|-
 +
|Table
 +
|RW
 +
|Character
 +
|Table name
 +
|-
 +
|valign="top"|Tables
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|
+
|valign="top"|Comma-separated list of table names
 
|-
 
|-
|valign="top"|
+
|valign="top"|UpdatableFieldList
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|
+
|valign="top"|Comma-separated list of fields
 
|-
 
|-
|valign="top"|
+
|valign="top"|TranslateName
 +
|valign="top"|RW
 +
|valign="top"|Boolean
 +
|valign="top"|Whether to translate underscores in remote table names to a dot
 +
|-
 +
|UpdateCmd
 +
|RW
 +
|Character
 +
|Update command string
 +
|-
 +
|valign="top"|UpdateNameList
 
|valign="top"|RW
 
|valign="top"|RW
 
|valign="top"|Character
 
|valign="top"|Character
|valign="top"|
+
|valign="top"|Comma-separated list of pairs of local and remote field names
 +
|-
 +
|valign="top"|UpdateType
 +
|valign="top"|RW
 +
|valign="top"|Numeric
 +
|valign="top"|Type of update: 1 = update old data with new data, 2 = delete old data and insert new data
 +
|-
 +
|valign="top"|UseMemoSize
 +
|valign="top"|RW
 +
|valign="top"|Numeric
 +
|valign="top"|Minimum size in bytes for returning a value as a memo field
 +
|-
 +
|valign="top"|WhereType
 +
|valign="top"|RW
 +
|valign="top"|Numeric
 +
|valign="top"|Type of fields used for where clauses: 1 = KeyFieldList, 2 = KeyFieldList and updatable fields, 3 = KeyFieldList and modified fields, 4 = KeyFieldList and comparison of time stamps
 
|-
 
|-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
|}
 
|}
  
Line 124: Line 222:
 
This class supports the [[:Category:Common_Methods|Common Methods]] plus the following:
 
This class supports the [[:Category:Common_Methods|Common Methods]] plus the following:
  
{| class="wikitable" width=100%
+
{| class="wikitable" width="100%"
 
!width="20%"|Method
 
!width="20%"|Method
 
!Args
 
!Args
 
!width="50%"|Description
 
!width="50%"|Description
 +
|-
 +
|Cancel
 +
|None
 +
|Cancel transaction
 +
|-
 +
|valign="top"|clearNamedParameter
 +
|valign="top"|None
 +
|valign="top"|Clear all named parameters previously set using setNamedParameter(name,value).  From v4.1.
 +
|-
 +
|Close
 +
|None
 +
|Close the DataSource
 +
|-
 +
|Commit
 +
|None
 +
|Commit transaction data changes
 +
|-
 +
|valign="top"|CursorFill
 +
|valign="top"|None
 +
|valign="top"|Fill the cursor based on SelectCmd
 +
|-
 +
|valign="top"|CursorRefresh
 +
|valign="top"|None
 +
|valign="top"|Refresh the cursor based on SelectCmd
 +
|-
 +
|valign="top2|Exec
 +
|command as Character
 +
|valign="top"|Execute the specified command
 +
|-
 +
|Open
 +
|None
 +
|Open the DataSource
 +
|-
 +
|valign="top"|queryBuilder
 +
|valign="top"|dbtype as Character, columnlist as Character,<br>valuelist as character, datatypes as character,<br>operators as character
 +
|valign="top"|Build a database-specific condition string for use with the requery() method.<br>From v5.4. See example [[#Example querybuilder()|below]].
 +
|-
 +
|valign="top"|Refresh
 +
|valign="top"|None
 +
|valign="top"|Refresh the cursor based on SelectCmd
 +
|-
 +
|valign="top"|Requery
 +
|valign="top"|whereclause as Character
 +
|valign="top"|Apply whereclause to SelectCmd and requery the cursor.  Notes: if the SelectCmd does not have an existing WHERE clause, requery() appends 'WHERE ' plus the specified whereclause to the end of the statement.  If the SelectCmd does have an existing WHERE clause, the requery() method replaces everything after the 'WHERE ' with the specified whereclause.  Other clauses following the original WHERE clause, e.g. group by, should be included in the whereclause or they will be removed.
 +
|-
 +
|Rollback
 +
|None
 +
|Rollback transaction data changes
 +
|-
 +
|valign="top"|setNamedParameter
 +
|valign="top"|name as Character, value as Character
 +
|valign="top"|Set the specified named parameter to the specified value. This can be used to set {parameter} or ?parameter macros in [[Virtual Tables|virtual table]] definitions.  From v4.1.
 +
|-
 +
|valign="top"|Sqlvalues
 +
|valign="top"|selectstatement as Character
 +
|valign="top"|Returns a comma separated list of values from the result of the singleton select SQL query specified in selectstatement.
 +
|-
 +
|valign="top"|Sync
 +
|valign="top"|None
 +
|valign="top"|Refresh the cursor to keep it in sync with the remote data source after an INSERT, DELETE or UPDATE operation while remaining on the same row.
 +
|-
 +
|Transaction
 +
|None
 +
|Begin transaction
 
|-
 
|-
 
|}
 
|}
 +
 +
=====Example querybuilder()=====
 +
<code lang="recital">
 +
ca = new cursorAdapter()
 +
? ca.queryBuilder("mssql", "territoryid,modifieddate,lower(msg)", "10,2020-10-31,hello world", "N,D,C", ">=,<=,=")
 +
// Return value for MS SQL Server:
 +
isnull(territoryid,0)>=10 and isnull(modifieddate,'')<='2020-10-31' and isnull(lower(msg),'')='hello world'</code>
  
 
====Events====
 
====Events====
Line 135: Line 304:
 
This class supports the [[:Category:Common_Events|Common Events]] plus the following:
 
This class supports the [[:Category:Common_Events|Common Events]] plus the following:
  
{| class="wikitable" width=100%
+
{| class="wikitable" width="100%"
 
!width="20%"|Event
 
!width="20%"|Event
 
!Args
 
!Args
 
!width="50%"|Description
 
!width="50%"|Description
 +
|-
 +
|valign="top"|afterCursorAttach
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs after cursoradapter is open
 +
|-
 +
|valign="top"|afterCursorClose
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs after cursoradapter is closed and after afterCursorDetach
 +
|-
 +
|valign="top"|afterCursorDetach
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs after cursoradapter is closed
 +
|-
 +
|valign="top"|afterCursorFill
 +
|valign="top"|cursorSchema as Character
 +
|valign="top"|Occurs after cursor is filled
 +
|-
 +
|valign="top"|afterCursorOpen
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs after cursoradapter is open and afterCursorAttach
 +
|-
 +
|valign="top"|afterCursorRefresh
 +
|valign="top"|alias as Character, refreshed as Boolean
 +
|valign="top"|Occurs after cursor is refreshed
 +
|-
 +
|valign="top"|afterCursorUpdate
 +
|valign="top"|rows as Numeric, result as Boolean, error as Character
 +
|valign="top"|Occurs after cursor is updated
 +
|-
 +
|valign="top"|afterDelete
 +
|valign="top"|fieldstate as Character, force as Boolean, deleteCmd as Character, deleted as Boolean
 +
|valign="top"|Occurs after delete operation is performed
 +
|-
 +
|valign="top"|afterInsert
 +
|valign="top"|fieldstate as Character, force as Boolean, insertCmd as Character, inserted as Boolean
 +
|valign="top"|Occurs after insert operation is performed
 +
|-
 +
|valign="top"|afterUpdate
 +
|valign="top"|fieldstate as Character, force as Boolean, insertCmd as Character, inserted as Boolean
 +
|valign="top"|Occurs after update operation is performed
 +
|-
 +
|valign="top"|beforeCursorAttach
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs before cursor is open and after beforeCursorOpen
 +
|-
 +
|valign="top"|beforeCursorClose
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs when close method is called
 +
|-
 +
|valign="top"|beforeCursorDetach
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs before cursoradapter is closed and after beforeCursorClose
 +
|-
 +
|valign="top"|beforeCursorFill
 +
|valign="top"|cursorSchema as Character, noDataOnLoad as Boolean, selectCmd as Character
 +
|valign="top"|Occurs before when cursorFill method is called
 +
|-
 +
|valign="top"|beforeCursorOpen
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs when open method is called
 +
|-
 +
|valign="top"|beforeCursorRefresh
 +
|valign="top"|alias as Character
 +
|valign="top"|Occurs when cursorRefresh method is called
 +
|-
 +
|valign="top"|beforeCursorUpdate
 +
|valign="top"|rows as Numeric, force as Boolean
 +
|valign="top"|Occurs before cursor is updated
 +
|-
 +
|valign="top"|beforeDelete
 +
|valign="top"|fieldstate as Character, force as Boolean, deleteCmd as Character
 +
|valign="top"|Occurs before delete operation is performed
 +
|-
 +
|valign="top"|beforeInsert
 +
|valign="top"|fieldstate as Character, force as Boolean, deleteCmd as Character
 +
|valign="top"|Occurs before insert operation is performed
 +
|-
 +
|valign="top"|beforeUpdate
 +
|valign="top"|fieldstate as Character, force as Boolean, deleteCmd as Character
 +
|valign="top"|Occurs before update operation is performed
 
|-
 
|-
 
|}
 
|}
Line 144: Line 393:
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Framework Classes]]
 
[[Category:Framework Classes]]
 +
[[Category:Third Party Database Connectivity]]
 +
[[Category:Virtual Tables]]
 +
[[Category:Lianja SQL]]

Latest revision as of 10:20, 2 October 2020

Note: property, method and event names should be referred to in lowercase in case-sensitive scripting languages.

Properties

This class supports the Common Properties plus the following:

Property Access (R/RW) Value Description
Alias RW Character Alias name
AllowDelete RW Boolean Whether delete operations are allowed
AllowInsert RW Boolean Whether insert operations are allowed
AllowSimultaneousFetch RW Boolean Whether simultaneous fetch operations are allowed
AllowUpdate RW Boolean Whether update operations are allowed
AutoSync RW Boolean Whether cursor is refreshed automatically when you insert, delete or update records so that the local cursor and the remote data source are kept in sync, but still on the same row as before the INSERT, DELETE or UPDATE operation.
BatchUpdateCount RW Numeric Number of update statements sent
BreakOnError RW Boolean Whether errors break program execution
CompareMemo RW Boolean Whether memos are included in where update clauses
ConversionFunc RW Character Comma-separated list of field and function name pairs
CursorSchema RW Character Structure of the cursor
Database RW Character Database name
DataSource RW Character Source of data
DataSourceHost RW Character Hostname or IP for DataSource
DataSourceOptions RW Character Options string for DataSource
DataSourcePassword RW Character Password for DataSource
DataSourcePort RW Numeric Port number for DataSource
DataSourceType RW Character Type of the DataSource: "LOCAL" or "ODBC"
DataSourceUsername RW Character Username for DataSource
Dbtype R Character Database type, e.g. "MYSQL", "MSSQL"
DeleteCmd RW Character Delete command string
FetchAsNeeded RW Boolean Whether records are fetched as needed
FetchSize RW Numeric Number of rows fetched
Flags RW Numeric Flag settings
InsertCmd RW Character Insert command string
KeyFieldList RW Character Comma-separated list of primary fields
MaxRecords RW Numeric Maximum number of rows returned
NoData RW Boolean Whether cursoradapter should return no data
Prepared RW Boolean Whether to prepare SQL statements for subsequent requery
QuoteString RW Character Replacement string for single quote characters
SelectCmd RW Character Select command string
SendUpdates RW Boolean Whether to send an update query
Table RW Character Table name
Tables RW Character Comma-separated list of table names
UpdatableFieldList RW Character Comma-separated list of fields
TranslateName RW Boolean Whether to translate underscores in remote table names to a dot
UpdateCmd RW Character Update command string
UpdateNameList RW Character Comma-separated list of pairs of local and remote field names
UpdateType RW Numeric Type of update: 1 = update old data with new data, 2 = delete old data and insert new data
UseMemoSize RW Numeric Minimum size in bytes for returning a value as a memo field
WhereType RW Numeric Type of fields used for where clauses: 1 = KeyFieldList, 2 = KeyFieldList and updatable fields, 3 = KeyFieldList and modified fields, 4 = KeyFieldList and comparison of time stamps

Methods

This class supports the Common Methods plus the following:

Method Args Description
Cancel None Cancel transaction
clearNamedParameter None Clear all named parameters previously set using setNamedParameter(name,value). From v4.1.
Close None Close the DataSource
Commit None Commit transaction data changes
CursorFill None Fill the cursor based on SelectCmd
CursorRefresh None Refresh the cursor based on SelectCmd
Exec command as Character Execute the specified command
Open None Open the DataSource
queryBuilder dbtype as Character, columnlist as Character,
valuelist as character, datatypes as character,
operators as character
Build a database-specific condition string for use with the requery() method.
From v5.4. See example below.
Refresh None Refresh the cursor based on SelectCmd
Requery whereclause as Character Apply whereclause to SelectCmd and requery the cursor. Notes: if the SelectCmd does not have an existing WHERE clause, requery() appends 'WHERE ' plus the specified whereclause to the end of the statement. If the SelectCmd does have an existing WHERE clause, the requery() method replaces everything after the 'WHERE ' with the specified whereclause. Other clauses following the original WHERE clause, e.g. group by, should be included in the whereclause or they will be removed.
Rollback None Rollback transaction data changes
setNamedParameter name as Character, value as Character Set the specified named parameter to the specified value. This can be used to set {parameter} or ?parameter macros in virtual table definitions. From v4.1.
Sqlvalues selectstatement as Character Returns a comma separated list of values from the result of the singleton select SQL query specified in selectstatement.
Sync None Refresh the cursor to keep it in sync with the remote data source after an INSERT, DELETE or UPDATE operation while remaining on the same row.
Transaction None Begin transaction
Example querybuilder()
ca = new cursorAdapter()
? ca.queryBuilder("mssql", "territoryid,modifieddate,lower(msg)", "10,2020-10-31,hello world", "N,D,C", ">=,<=,=")
// Return value for MS SQL Server:
isnull(territoryid,0)>=10 and isnull(modifieddate,'')<='2020-10-31' and isnull(lower(msg),'')='hello world'

Events

This class supports the Common Events plus the following:

Event Args Description
afterCursorAttach alias as Character Occurs after cursoradapter is open
afterCursorClose alias as Character Occurs after cursoradapter is closed and after afterCursorDetach
afterCursorDetach alias as Character Occurs after cursoradapter is closed
afterCursorFill cursorSchema as Character Occurs after cursor is filled
afterCursorOpen alias as Character Occurs after cursoradapter is open and afterCursorAttach
afterCursorRefresh alias as Character, refreshed as Boolean Occurs after cursor is refreshed
afterCursorUpdate rows as Numeric, result as Boolean, error as Character Occurs after cursor is updated
afterDelete fieldstate as Character, force as Boolean, deleteCmd as Character, deleted as Boolean Occurs after delete operation is performed
afterInsert fieldstate as Character, force as Boolean, insertCmd as Character, inserted as Boolean Occurs after insert operation is performed
afterUpdate fieldstate as Character, force as Boolean, insertCmd as Character, inserted as Boolean Occurs after update operation is performed
beforeCursorAttach alias as Character Occurs before cursor is open and after beforeCursorOpen
beforeCursorClose alias as Character Occurs when close method is called
beforeCursorDetach alias as Character Occurs before cursoradapter is closed and after beforeCursorClose
beforeCursorFill cursorSchema as Character, noDataOnLoad as Boolean, selectCmd as Character Occurs before when cursorFill method is called
beforeCursorOpen alias as Character Occurs when open method is called
beforeCursorRefresh alias as Character Occurs when cursorRefresh method is called
beforeCursorUpdate rows as Numeric, force as Boolean Occurs before cursor is updated
beforeDelete fieldstate as Character, force as Boolean, deleteCmd as Character Occurs before delete operation is performed
beforeInsert fieldstate as Character, force as Boolean, deleteCmd as Character Occurs before insert operation is performed
beforeUpdate fieldstate as Character, force as Boolean, deleteCmd as Character Occurs before update operation is performed