[anydac][DApt]-400.Fetch command fetched[0] instead of [1] record,
Possible reasons:update table does not have PK or row identifier,record has been changed/deleted by another user,
when executing
SingleTestRunADQuery.Append();
SingleTestRunADQuery.FieldByName('run_id').Value := StartRecordingButton.Tag;
SingleTestRunADQuery.FieldByName('ph_value').Value := FloatToStr(ph_reading);
SingleTestRunADQuery.FieldByName('conductivity_value').Value := conductivity_reading;
SingleTestRunADQuery.FieldByName('cod_value').Value := cod_reading;
SingleTestRunADQuery.Post();
on
mysql> describe measurements;
+------------------------+-----------+------+-----+-------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------+------+-----+-------------------+-------+
| run_id | int(11) | NO | MUL | NULL | |
| measurement_time_stamp | timestamp | NO | PRI | CURRENT_TIMESTAMP | |
| ph | float | NO | | NULL | |
| conductivity | float | NO | | NULL | |
| cod | float | NO | | NULL | |
+------------------------+-----------+------+-----+-------------------+-------+
5 rows in set (0.03 sec)
as you can see, the table does have a PK. Also, the program is single-threaded and only one copy is running, so no one else is updating.
I set SingleTestRunADQuery.MasterFields=run_id and IndexFieldNames=run_id as that is the PK of table which holds a summary of all test runs. The second table hold the measurements taken during tests, with run_id giving all the measurements for one test run (I only added PK on tiemstamp to get rid of this error, but it didn't work and can be removed, I guess).
In case it helps, here's the master data source:
mysql> describe test_runs;
+------------------+-------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+-------------+------+-----+-------------------+----------------+
| run_id | int(11) | NO | PRI | NULL | auto_increment |
| start_time_stamp | timestamp | NO | | CURRENT_TIMESTAMP | |
| end_time_stamp | timestamp | YES | | NULL | |
| description | varchar(64) | YES | | NULL | |
+------------------+-------------+------+-----+-------------------+----------------+
4 rows in set (0.05 sec)
Any idea what's wrong?
[Update] # mj2008 points out that some fields have different names. This is for historical reasons (I am still trying something out & don't want to change yet), hoever these are adapted by the query:
SELECT run_id,
measurement_time_stamp,
ph as ph_value,
conductivity as conductivity_value,
cod as cod_value
FROM photo_catalytic.measurements
ORDER BY measurement_time_stamp DESC
I'm not sure that is correct to have TIMESTAMP field as PRIMARY KEY. It will automatically change on every UPDATE.
Check out to the TFields property of Query component, through "Fields Editor" option. check that "Key Fields" has a ProviderFlags.pfInKey property set to true.
This applies today to FireDac components.
You should change the connection properties as follows: Try setting UpdateOptions.RefreshMode to rmManual.
enter image description here
check if timestamp that is on database doesnot hav seconds and miliseconds
Related
I have a mariadb table as follows:
This is an example of how a row looks like
| 4 | test/1ecb5e71-9105-4a0c-8fa1-7fc8d5e970bd/kuva.jpeg | {"Records":
The content in Records have been omitted to keep it short and simple. When I issue SQL select like this select key_name from minio_images where id=4;, it returns me a normal output like this
+-----------------------------------------------------+
| key_name |
+-----------------------------------------------------+
| test/1ecb5e71-9105-4a0c-8fa1-7fc8d5e970bd/kuva.jpeg |
+-----------------------------------------------------+
1 row in set (0.09 sec)
My question is how can I use select so that it just returns me the UUID in key_name instead of the whole string. For example, 1ecb5e71-9105-4a0c-8fa1-7fc8d5e970bd and not test/1ecb5e71-9105-4a0c-8fa1-7fc8d5e970bd/kuva.jpeg? I'd really appreciate any sort of help with this.
Luckily, I found a similar post # extract substring from mysql column using regex and I tried a solution suggested there, by issuing a SELECT statement which I guess, returns the value from a column based on the regular expression. In my case, the regular expression to extract UUID is '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}' and the statement was like
SELECT REGEXP_SUBSTR(key_name, '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')
FROM minio_images;
Which gave me an output, just like I needed
+--------------------------------------------------------------------------------------------------------+
| REGEXP_SUBSTR(key_name, '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}') |
+--------------------------------------------------------------------------------------------------------+
| 1ecb5e71-9105-4a0c-8fa1-7fc8d5e970bd |
| 1edd460e-b19a-4b16-a460-d433eac60833 |
| 281a890f-0b8b-4693-9227-fc8c57d6045e |
| 37a14ddb-eeda-41f2-a2b6-ec0bad34aaed |
| 37d4f3d2-2282-4b9f-8e1e-f8a26570c5b4 |
| 387da0c1-1caf-4394-a023-92e7eec19b66 |
| 49a29478-4799-4a8b-8757-42060020fc99 |
| 9214e1f0-77e3-435a-a329-d1829a973903 |
| ae67c69a-a2cf-4c21-88ca-bd17e254bc4c |
| b6491e64-34a6-4aa3-a54e-200b1cd946fe |
| c0f6864b-2ab8-41fa-a1c2-6b974a1895c1 |
| cfd61927-557e-47d2-aeb9-229ec1aba5b4 |
| df566110-c2a0-4d9c-8389-fcbaf6c8bb30 |
+------------------------------------------------------------------------------------- -------------------+
16 rows in set (0.03 sec)
We currently capture data from HL7 messages like below and then insert the same in database. This is easy as it is value from a single segment
var vACC_NO =checkSize("ACC",msg['PID']['PID.3']['PID.3.1'].toString(),20);
INSERT INTO adt_tab ( SITEID,ACC_NO) VALUES (vSITEID,vACC_NO);
Now I need to capture DG1 segment data, where we have multiple DG1 segments in HL7 message. And also need to store in Database
| DG1 | 1 | ICD10 | I22.8^MYOCARDIAL INFARCT^ICD10 | MYOCARDIAL | | | | | | | | | | | |
| INFARCTION | 201702010437 | B | | | | | | | | | 7 | | | | |
| DG1 | 2 | ICD10 | A44.9^ORGANISM^ICD10 | ORGANISM | 20170201 0437 | B | | | | | | | | | 7 |
So in my database table I have now more columns - SITEID, ACC_NO, CODE1, CODE2...
From the above message I need to insert I22.8 into CODE 1, A44.9 into CODE2 and so on ..
How I should first capture these codes in loop from multiple DG1 segments in the message ?
And then how I should store it in the database ?
Thanks
You can iterate over the segments like this
for each (dg1 in msg['DG1']){
variable1 = dg1['DG1.3']['DG1.3.1'];
variable2 = dg1['DG1.3']['DG1.3.2'];
// database call with the previus
databaseCall(variable1,variable2, ...
}
For each segment you are going to do an insert.
Apart from this, I do not think is a good idea to make more columns in the same row by adding variable1, variable2, variable3 ... as it is not normalized and it not a good database design practice.
I'm trying to get some data on how long it takes for reviews to go through Gerrit on average.
Looking at some open source code, I see stuff like
reviewCreateTime = moment(mergedReviewsList[review].created);
reviewUpdateTime = moment(mergedReviewsList[review].updated);
interval = reviewUpdateTime.diff(reviewCreateTime, TIME_PERIOD_TYPE);
But with experimentation I don't think this logic is correct because adding a comment to a merged CR changes the updated timestamp.
I know this is possible because at the time of merge, Gerrit prints to the UI Change has been successfully merged by XXX.
I've been digging around in the mysql database but haven't found anything useful. I notice that changes that have been submitted have a submission_id, but I haven't found a table that stores submission information.
After a bunch of digging around, I have come up with one rather ugly but workable solution.
There is a table change_messages
mysql> describe change_messages;
+-----------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+-------------+------+-----+---------+-------+
| author_id | int(11) | YES | | NULL | |
| written_on | timestamp | NO | | NULL | |
| message | text | YES | | NULL | |
| patchset_change_id | int(11) | YES | MUL | NULL | |
| patchset_patch_set_id | int(11) | YES | | NULL | |
| change_id | int(11) | NO | PRI | 0 | |
| uuid | varchar(40) | NO | PRI | | |
+-----------------------+-------------+------+-----+---------+-------+
7 rows in set (0.00 sec)
This basically stores stuff like XXXX has been successfully merged by YYYY and XXXX has been successfully cherry-picked as YYYY by ZZZZ.
You can then join this table with changes and datediff on change_messages.written_on and changes.created_on, e.g.
SELECT changes.change_id,
created_on,
written_on,
Datediff(written_on, created_on) diff
FROM change_messages
INNER JOIN changes
ON change_messages.change_id = changes.change_id
WHERE message LIKE 'Change has been successfully merged by %'
ORDER BY written_on;
Now this includes any time the CR was in draft mode. I'll edit this question if I get around to excluding that time.
I'm attempting to write an app that allows users to register different id numbers to their account through the use of a form. The ids have their own model and the table is as follows:
mysql> show columns in hp_ids;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| id_string | varchar(255) | YES | | NULL | |
| pin_number | int(11) | YES | | NULL | |
| user_id | int(11) | YES | MUL | NULL | |
| created_at | datetime | YES | | NULL | |
| updated_at | datetime | YES | | NULL | |
+------------+--------------+------+-----+---------+----------------+
The id number is saved under id_string
The trick is that, in order to register an id, a user must enter its corresponding pin to prove that they have the right to register it..
What I want to do is, each time someone attempts to register a new id/pin combination, I would like to check it against a key of sorts to make sure that they have the right combination. I figure I would create a new model called IdKey or something like that but I can't figure out how I would tell the controller to check the form values against this second model prior to saving them.
Could anyone point me in the right direction?
It sounds like a conditional or custom validation.
I may be misunderstanding your question, but is pin_number a preexisting value? If so, I'd guess it should exist in a different table (which could be queried during your custom validation).
I'm working on an app at work where users can upload files to a project. Right now I'm using paperclip, and all of the file info (name, file type, etc.) is recorded properly.
The problem I'm having is that the users need to assign a category to each file.
What is the best approach to implement something like this? I'm on my phone right now, but I'll attach any pertinent code when I get to work, if necessary.
Thanks in advance!
EDIT
Here's more info on the setup.
I need to assign the file type (which is more like a category than a file type. I didn't name the fields!) So all of the info is in a single table. Although accepts_nested_attributes will definitely come in handy down the road!
Here's the table structure. All of the document_ fields are set by paperclip. The only one that needs user input is the file_type field.
+-----------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| document_file_name | varchar(255) | YES | | NULL | |
| document_content_type | varchar(255) | YES | | NULL | |
| document_file_size | int(11) | YES | | NULL | |
| document_updated_at | datetime | YES | | NULL | |
| project_id | int(11) | YES | MUL | NULL | |
| user_id | int(11) | YES | MUL | NULL | |
| file_type | varchar(255) | YES | | NULL | |
| created_at | datetime | NO | | NULL | |
| updated_at | datetime | NO | | NULL | |
+-----------------------+--------------+------+-----+---------+----------------+
According to Zippie, you can check Nested Model form. I'm also not sure if it works for files. You can get ideas from this tutorials.