Options property
Previous  Top  Next

See Also Properties Methods Events Example
Unit
MySQLDataset

Applies to
TMySQLDataset TMySQLTable and TMySQLQuery components

Declaration
TMySQLDatasetOptions = set of (doShareConnection,doCachedUpdates,doThreadedUpdate,doFieldsAsString,doRetrieveFieldValues,doMacrosEnabled,doMacroCheck,do2KStrToMemo,doSmallMemoToStr,doEnumToBool,doSetToWord,doEditCalcFields,doUseCursor);

property Options: TMySQLDatasetOptions default [doShareConnection,doMacrosEnabled,doMacroCheck,do2KStrToMemo,doRetrieveFieldValues,doUseCursor];

Description
These options controls much of the behaviour of your dataset concerning connections, threads, updates, fields, macros and how data is presented to your application, and even if the dataset should show the default SQL type cursor when it queries the mysql server or sends an update.

Options
Description
doShareConnection
If disabled this dataset will acquire a new connection/thread to the MySQL server from it's TMySQLServer using the same settings. The equivalent property is ShareConnection.
doTransactions
If enabled, this dataset will automatically prefix your SQLUpdate/SQLInsert/SQLDelete property statements with a "start transaction;" and postfix it with a "commit;" when they are executed. If an exception occurs while executing any of the enclosed sql statements, a "rollback;" will be issued and send automatically to the MySQL server and the exception raised for you to handle. This option has no effect if your MySQL server is pre version 4.0.11.
doRecursiveUpdates
If enabled on the dataset and you have specified SQL which selects from two or more tables, the dataset will execute the update, delete and insert SQL once for each table which are part of the select. Ex. select * from accounts,orders where accounts.ID=orders.AccID will result in a multitable result. If you update columns from the accounts and orders tables before posting, the dataset will generate update SQL for each table, once containing the changed columns from the accounts table and once containing the changed columns for the orders table. If only one table's columns have changed, then only one SQL statement will be generated, instead of two. NOTE: With the default Update/Insert/Delete SQL, you should make sure your accounts and orders tables both contain primary keys and primary key columns of both tables are part of the available columns in the select.
doCachedUpdates
If enabled this dataset will collect all updating type sql statements, ie update/insert/delete, into a separate list, SQLCached, and try to execute it only when you close or refresh this dataset. On your clientside you will see no differences, because the end user is editing local data.
doAutoCreate
If enabled, this dataset will create it's table/structure IF it does not exist in the current database when it activates. The dataset should be simple, i.e. no joins or data from multiple tables, and the TableName property should contain a value. The IndexDefs and FieldsDefs will be used for purposes of building a "create table .." statement. If no FieldDefs or IndexDefs are defined, then this will create a table with a name TableName containing a single AUTOINC column, ID, which is also the primary key. If True this option also makes this dataset available to it's TMySQLServer 's CreateDatabase method and it's soAutoCreate option. NOTE: You may wish to disable this option after the table has been recreated successfully, otherwise this create script will be executed everytime the TMySQLDataset connects. Because it uses "IF NOT EXISTS" SQL this won't cause any harm, but it is additional work to be done by both your application and the mysql server.
doCreateTemp
If doAutoCreate is enabled and this setting is enabled the compiled sql will create only a temporary table, thus one only visible to this connection and only persisting while this connection is active. This setting is also used with the CreateTable method.
doDropIfExists
If doAutoCreate is enabled and this setting is enabled the compiled sql will be prefixed with a "drop table if exists.." statement. This setting is also used with the CreateTable method. WARNING: Be very, very careful with this option, if it is enabled on an existing table and the dataset is activated, even just at designtime you will lose all data in this table and the table will then be recreated using the FieldDefs and IndexDefs settings.
doThreadedUpdate
If enabled, this dataset will execute all updating type sql statements, ie update/insert/delete, on a separate thread instead of your main application thread, which means that your mains application will keep running even if an update might take a few minutes to finish. See also the Execute method
doFieldsAsString
This will present the data from the mysql server as TStringFields instead of for example converting the DATE columns to TDateFields as an example. Thus you get access to your RawData.
doRetrieveFieldValues
When True, this will cause your dataset to execute a "show columns" on the tables included in this query after all the data has been fetched from your server. The primary goal of this is to enabled you to have your mysql table's default values appear right in your dbedit/grid controls when you insert a new record, as well as have available your SET and ENUM values in the TMySQLStringFields which gets created for them.
doRetrieveIndexDefs
When True, this will cause your dataset to execute a "show index" on the table included in the query after all the data has been fetched from your server. The primary goal of this is to enabled you to have your IndexDefs populated with the actual indexes of the mysql table which is used in the CreateTable method. The "show index" is only done if you have selected fields from a single table.
doMacrosEnabled
If True, this will cause the dataset to parse all your sql statements and properties to search for Macros and populate the Macros property.
doMacroCheck
If True, this will cause the dataset to clear all your macros before it parses all the sql properties.
do2KStrToMemo
If True, this will cause the dataset to convert all mysql VARCHAR columns larger than 2048 bytes to TMemoFields in your application which in turn means you can edit these large strings with a dbmemo controls instead of small dbedit controls.
doSmallMemoToStr
This is the inverse of the do2KStrToMemo. If True, this will cause the dataset to create TStringFields for all MEMO mysql columns smaller than 64K.
doEnumToBool
This is very useful with some edit controls. If True, it will cause all ENUM columns with only two values to be presented as TBooleanFields.
doSetToWord
Another useful one, if True, it will cause all SET mysql columns to be presented as TWordFields. Editing the word values will also select different members in the set for example, 101Binary = 5Decimal = 1 and 3 member of the set will become selected in your SET column.
doEditCalcFields
Another useful feature, if True, it will enable you to edit calculated fields. For example say you have an SQL that looks like this:
select MyNoID, (MyNo1 + MyNo2) as MyNo1 from MyNumbers
The MyNo1 field would normally not be editable as it is a calculated column returned by mysql. But setting this property to True you can fool mysql if you wanted to end user to update the MyNo1, because the datasets will now allow you to edit the column and generate an update like:
update MyNumbers set MyNo1=1354325 where MyNoID=1234;
doUseCursor
If True, this will change your mouse cursor in your application to the SQL cursor each time this dataset executes an sql statement to the mysql server. Same result as setting the UseCursor property.