Page 1 of 1
Selective update MySQL
Posted: Fri 16 Sep 2016 04:10
I have created a new record in one UniQuery and posted it. I know the id of the key field. Now i need to refresh another UniQuery that is linked to the same MySql Table, but without reloading all the rows from the server, just the one row that was inserted from the fist UniQuery. Is it posible?
If not (and even better), can i by code copy the new row from query1 to query2 without Query2 talks to the server?
Re: Selective update MySQL
Posted: Fri 16 Sep 2016 09:26
by ViktorV
MySQL doesn't provide a capability to retrieve information about changes made in another query without request to the server. For quick retrieving of changes made by other quires, you can use the TCustomDADataSet.RefreshQuick method. Note, that usage of this method requires the table to have unique key fields and a TIMESTAMP field. See more details about this method in MyDAC help:
https://www.devart.com/mydac/docs/devar ... olean).htm
Re: Selective update MySQL
Posted: Fri 16 Sep 2016 12:53
I get Error "Timestamp field is reqierd, but i have a timestamp"?
Code: Select all
CREATE TABLE olf.customers (
id_customer int(11) NOT NULL AUTO_INCREMENT,
name_customer varchar(90) DEFAULT NULL,
levadr varchar(255) DEFAULT NULL,
postadr varchar(255) DEFAULT NULL,
email varchar(255) DEFAULT NULL,
fax varchar(255) DEFAULT NULL,
nofemp int(11) DEFAULT NULL,
telvaxel varchar(255) DEFAULT NULL,
vatnbr varchar(255) DEFAULT NULL COMMENT 'Tax identification number',
officetype varchar(255) DEFAULT NULL COMMENT 'Head Or Bransch',
customertype varchar(255) DEFAULT NULL,
notes mediumblob DEFAULT NULL,
timestamp timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id_customer, timestamp),
UNIQUE INDEX idx_customers_id_customers (id_customer)
)
ENGINE = MYISAM
AUTO_INCREMENT = 151
AVG_ROW_LENGTH = 8192
CHARACTER SET utf8
COLLATE utf8_general_ci;
Re: Selective update MySQL
Posted: Fri 16 Sep 2016 14:10
by ViktorV
This error occurs on calling the TMyQuery.RefreshQuick method, when the SELECT query, that is set in the TMyQuery.SQL.Text property, doesn't contain a timestamp field.
To solve the issue, please add a timestamp field to the SELECT query and redefine it in the table:
from
Code: Select all
timestamp timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP
to
Code: Select all
timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP