I am using DBFL_SQL_6 library to read and write data to MariaDB. I used MariaDB example (DBFL_SQL_*_EXA_MYSQL // MariaDB) on the DBFL_SQL_6-manual to get started and got reading and writing to work.
* I have tried to write STRING-variable to the database with DBFL_StrToComT2_1 FB but havent got that working. FB is missing IN_bLastChar-input to enter separator/conluding character. Does that mean i should use this in some other way or does it mean that STRING-values cannot be written to the database?
* Another problem is that if i want to, for example, write 50 rows with 9 columns then it takes 28 seconds to process. Im writing as in the example and when one row is finished, change data and loop back to write with new data. I guess the problem is that FB's write/read one value to the database at a time and this is probably not possible to change so it would write/read more data at once?
What is your task interval?
Are you using the FIFO FB?
Have you tried formatting the command manually into 18 separate strings to send to DBFL_CODE FB?
I haven’t tested this in a while so maybe you can confirm, if the DBFL_StrToComT2 block is activated does OUT_DataValid get set in the same scan or next scan?
I typically skip the conversion function blocks and format the command manually to the 18 individual strings. Then send those to the DBFL_CODE directly. Doing so on a 50ms task interval, I average about 300ms per transaction. Depending on the length of the data you’re trying to insert per row, you may or may not be able to fit 50 rows in a single command. Even if you can only fit 1 row per command you should be able to execute faster than 50 rows per 28 seconds.
Hi, thanks for reply
What is your task interval? → 100ms
Are you using the FIFO FB? → No
Have you tried formatting the command manually into 18 separate strings to send to DBFL_CODE FB? → No
Do you mean DBFL_IntToComT2_etc… function blocks when you say skipping conversion function blocks?
Figured out that skipping of conversion functions blocks and just manually added INSERT query with needed values, like you suggested and its working nicely, thank you for the tip!
As for string-variables, this should also be solved with this method but for some reason im getting an error „‚Unknown column ‚4225145748L‘ in ‚field list‘‘“ if i try to add characters. MariaDB column type is TEXT.
Tough to guess without seeing the full query string. I’ve found it hard to catch mistakes when the string is broken up into 18 individual strings so I’d recommend using the BUF_TO_STRING block to convert the full command buffer (DBFL_ARR_BYTE_0_1439) to a string. Copy that out to SSMS/MySQL Workbench and look for any syntax errors.
I ran into a new problem:
I have two different main programs and function blocks to write into the database and both were already working. Now for other function block im getting TCP_status error code: 109668. I am writing on the same database but different table with both (not at the same time). Other main/FB’s are working (although sometimes also that gives an error TCP_Status error code: 109680)
I can see that there are TCP error codes in the FB manual but im not sure how to exactly read them. I have checked many times that the both programs should be essentially the same and no idea why other one is not working.
I have copied the output string and inserted that straight (with HeidiSQL) to the database to see that the query is ok.
I haven’t used DBFL_MySQL_Access so I don’t feel very helpful in trying to diagnose that specific error code. I would think the table under section 8.5 would be the first place to look, but your error code seems abnormally high for the codes listed in that table. Maybe reach out to the DBFL_SQL_6 developers through the store?
You say each insert worked independently? Are you sure they’re not trying to execute at the same time?
The way my program is structured, all DB related FB’s are in one program. To handle multiple queries and keep the programming separate, I use separate FB’s for each query. Then some additional, custom FB’s to ensure only one command executes at a time. Not sure if you can architect your program that way, but it has worked for me.
Seems like the problem was that i had updated to newer version of PLCnext (2022.3). Tried with older version and its working fine. Hopefully that was it, thank you for the help!
Hi there, how do you manage to avoid using the conversion function blocks?
I tried this, but doesn’t work
…
udtMySQL_FB.udtDBFL_StartComT2.strStartString := ‚INSERT INTO example (Column1, Column2, Column3, Column4, Column5) VALUES (1,2,3,4,5)‘;
udtMySQL_FB.udtDBFL_StartComT2.xActivate := TRUE;
IF udtMySQL_FB.udtDBFL_StartComT2.xDataValid = TRUE THEN
udtMySQL_FB.udtDBFL_MYSQL_ACCESS.xDB_Activate := TRUE;
…