Error when inserting Hungarian text characters - character-encoding

I'm trying to insert this text via SQL query
INSERT INTO `tbl_instructions` (`No`, `Language`, `Text`) VALUES
('Introduction','HU','Kérdőív - ""Ismerd meg Önmagad!"" Ahogy az ókori görögök mondták: ""Ismerd meg Önmagad!"" - Ez a célja ennek a személyiségtesztnek is. Ez a teszt egy negyedórás szemtől szembeni beszélgetésnek felel meg. A teszt kitöltése nagyjából fél órát igényel. Közben megszakíthatja az internetkapcsolatot, elég a teszt elküldéséhez visszaállítania azt. Jó szórakozást kívánunk a teszthez, természetesen az adatait bizalmasan kezeljük és nem osztjuk meg senkivel. Ezt garantálja Andreas és Telse Gross');
and I'm getting:
#1366 - Incorrect string value: '\xC5\x91\xC3\xADv ...' for column
my_database.tbl_instructions.Text at row 1
I tried utf8_unicode_ci and UTf8mb4_unicode_ci and I'm still getting the same error.

This is likely to be a collation issue with the Text column in the target table.
Consider the following, which uses a Text column created with the latin1_general_ci collation:
CREATE TEMPORARY TABLE `tbl_instructions` (`Text` VARCHAR(1000) COLLATE latin1_general_ci);
INSERT INTO `tbl_instructions` (`Text`) VALUES ('Kérdőív - ""Ismerd meg Önmagad!"" Ahogy az ókori görögök mondták: ""Ismerd meg Önmagad!"" - Ez a célja ennek a személyiségtesztnek is. Ez a teszt egy negyedórás szemtől szembeni beszélgetésnek felel meg. A teszt kitöltése nagyjából fél órát igényel. Közben megszakíthatja az internetkapcsolatot, elég a teszt elküldéséhez visszaállítania azt. Jó szórakozást kívánunk a teszthez, természetesen az adatait bizalmasan kezeljük és nem osztjuk meg senkivel. Ezt garantálja Andreas és Telse Gross');
This produces the following error:
Error Code: 1366. Incorrect string value: '\xC5\x91\xC3\xADv ...' for
column 'Text' at row 1
Now consider the following, that uses utf8mb4_0900_ai_ci:
CREATE TEMPORARY TABLE `tbl_instructions` (`Text` VARCHAR(1000) COLLATE utf8mb4_0900_ai_ci);
INSERT INTO `tbl_instructions` (`Text`) VALUES ('Kérdőív - ""Ismerd meg Önmagad!"" Ahogy az ókori görögök mondták: ""Ismerd meg Önmagad!"" - Ez a célja ennek a személyiségtesztnek is. Ez a teszt egy negyedórás szemtől szembeni beszélgetésnek felel meg. A teszt kitöltése nagyjából fél órát igényel. Közben megszakíthatja az internetkapcsolatot, elég a teszt elküldéséhez visszaállítania azt. Jó szórakozást kívánunk a teszthez, természetesen az adatait bizalmasan kezeljük és nem osztjuk meg senkivel. Ezt garantálja Andreas és Telse Gross');
This runs successfully.
Simply specifying the collation on INSERT is not good enough - if the target column is an incompatible collation then you will get the error message you are seeing.
The table should be modified to be the correct collation - I am not suggesting it should be utf8mb4_0900_ai_ci. Use the collation that is appropriate for your needs (for example, latin2_general_ci also works for your character set).
Update following OP changing RDBMS to MariaDB instead of MySQL
Following your comment about using MariaDB instead of MySQL, you could use utf8mb4_general_ci which is available in MariaDB 10.2.
Here's a working fiddle for MariaDB 10.3 showing it working using that collation.

Related

Calling Package from Stored Procedure - Db2 z/OS

I´ve been trying to call a Package from a Stored Procedure, but I'm not able to.
I tried to create it as below:
CREATE PROCEDURE DGOWNDB.ZHG0002I
(IN col1 CHAR (03) FOR SBCS DATA CCSID EBCDIC,
IN col2 CHAR (20) FOR SBCS DATA CCSID EBCDIC,
IN col3 CHAR (03) FOR SBCS DATA CCSID EBCDIC)
DYNAMIC RESULT SETS 1
NOT DETERMINISTIC
LANGUAGE COBOL
FENCED
WLM ENVIRONMENT ENVWLM
BEGIN
EXTERNAL NAME 'PHGS222E'
;
I'm getting the Db2 error code -444, saying that it's not able to found the package
DSNT408I SQLCODE = -444, ERROR: USER PROGRAM PHGS222E COULD NOT BE FOUND
DSNT418I SQLSTATE = 42724 SQLSTATE RETURN CODE
DSNT415I SQLERRP = DSNX9CAC SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD = 0 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
I've tried to use both SET CURRENT PACKAGESET and CURRENT PACKAGE PATH special register but had no success.
I've tried to search but didn't find anything that helped. Insight from others is welcome.
Regards

q/kdb+ new version 4.0 parse error reading large tables from previous version

Is there any solution other than saving as csv and reloading in the new version...
KDB+ 4.0 2020.05.04 Copyright (C) 1993-2020 Kx Systems
m64/ 8(16)core 32768MB georgelovas ... 127.0.0.1 EXPIRE 2020.08.26
'parse `:../marketdata/tx
[0] (.Q.l)
With the old version...
KDB+ 3.6 2019.08.20 Copyright (C) 1993-2019 Kx Systems
m64/ 8(16)core 32768MB ... 127.0.0.1 EXPIRE 2020.08.26
q)count tx
2521171492
q)
Table info...
q)meta tx
c | t f a
------| -----
DATE | d
TICKER| s
FIELD | s
VALUE | f
q)t
DATE TICKER FIELD VALUE
-------------------------------------------------------------------
1998.01.31 XXXXXXX INDEX FIELD_1 -881
1998.01.31 XXXXXXX INDEX FIELD_2 -604
1998.01.31 XXXXXXX INDEX FIELS_3 0
1998.01.31 XXXXXXX INDEX FIElD_4 1.998031e+07
1998.02.28 XXXXXXX INDEX FIELD_1 -544
1998.02.28 XXXXXXX INDEX FIELD_2 -475
1998.02.28 XXXXXXX INDEX FIELS_3 0
1998.02.28 XXXXXXX INDEX FIElD_4 1.998041e+07
I see you are using:
KDB+ 4.0 2020.05.04
After reading the release notes, in the 2020.06.18 version there was a bug fix where reading an object exceeding 2GB in serialized form as part of a compound object from a single file was throwing a parse error since 3.7t 2019.10.22. Your version that works is 3.6. So this may be the answer to your problem.
Have you tried using \l from within a q session to load the table ?
The error your output seems to be showing is when loading the data from the command line.
Can you give more information on what the table consists of, meta etc.?
We may need more information around the table meta to replicate.
Can you tell us what the tx looks like?

Firedac TFDquery.RowsAffected - returns 1 when should return 0

I have a table 'EMAIL' with unique field 'addr'. When I make a query from mysql console (via Putty) it returns '0 rows affected' (since the 'id' didnt actually change), but FIREDAC always returns rowsAffected=1 (or 2 or 3 if there are more fields). Why is it so, how do I fix that?
+----+-------+------+------+
| id | owner | addr | pass |
+----+-------+------+------+
| 1 | NULL | test | NULL |
+----+-------+------+------+
mysql> update EMAIL set id=last_insert_id(id);
Query OK, 0 rows affected (0.00 sec) // 0 affected!
Rows matched: 1 Changed: 0 Warnings: 0
FIREDAC (FDconnection + FDquery)
procedure test;
var conn:TFDCONNECTION;
query:TFDQUERY;
begin;
conn:=TFDCONNECTION.Create(nil);
query:=TFDQUERY.Create(nil);
query.Connection:=conn;
conn.Params.Add('DriverID=MySQL');
conn.Params.Add('CharacterSet=utf8');
conn.Params.Add('Server=192.168.56.11'); //ubuntu server, v 14.14 5.7.30
conn.Params.Add('User_Name=root');
conn.Params.Add('Password=mypass');
conn.Params.Add('Database=MYDB');
conn.Params.Add('Port=3306');
query.SQL.Text:='update EMAIL set id=last_insert_id(id)';
query.ExecSQL;
//never shows '0', always thinks all the rows have been updated!
showmessage(inttostr( query.RowsAffected ));
query.Close;
conn.Free;
query.Free;
end;
[SOLVED!] I edited the source code of 'FireDAC.Phys.MySQL', line 471, commented out the 'CLIENT_FOUND_ROWS' flag (thanks to #Olivier)
For a MySQL database, in the case of UPDATE queries, the number of affected rows (returned by mysql_affected_rows()) depends on the CLIENT_FOUND_ROWS flag.
If the flag is disabled, then only records that are actually modified are taken into account.
If the flag is enabled, then all processed records (whether they are modified or not) are taken into account.
By default, CLIENT_FOUND_ROWS is disabled, but FireDAC enables it when it calls mysql_real_connect().

what is the default value for IBM Informix set isolation level

1 the stored procedure
create procedure sp_count_demo(
i_user_id varchar(30)
)
returning p_count as num_of_row ;
define p_count integer ;
set isolation to dirty read ;
let p_row = 0 ;
select count(*)
into p_count
from some_table a
where a.user_id = i_user_id
;
return p_row;
end procedure ;
2 The procedure at (1) will be called from java webapps with connection pool
3 Do I need to set the isolation level back to previous value before returning the result? (ie to avoid another process reusing the connection from having "dirty read" isolation level)
4 What is the default isolation level
5 Where/How can I get the default value for isolation level
Thanks in advance
Since a connection pool is in use the stored procedure should return the isolation level to its previous setting in order to avoid unexpected results when another app uses the same connection. The default isolation level depends on the logging mode of the database:
For an unlogged database it will effectively be "Dirty Read" (shown as NL by the onstat -g ses command).
For a mode ANSI database it will be "Repeatable Read."
For other logged databases it will be "Committed Read."
The onconfig parameter USELASTCOMMITTED can also be used to change how the default isolation level is used. More information on that can be found in the Knowledge Center (search on USELASTCOMMITTED).
It is possible for a session to find out its current isolation level using a query against the sysmaster database. This query was run on Informix 12.10 but should also be valid for 11.70:
select tx.isolevel
from sysmaster:systxptab tx, sysmaster:sysrstcb r, sysmaster:sysscblst s
where s.address = r.scb and tx.owner = r.address
and s.sid = dbinfo("sessionid");
It returns the isolation level as an integer which is an internal value - for example committed read has value 2. I don't believe the mapping of isolation level to integer value is published so you will need to experiment with setting different levels for a session and then running the above query.

Firebird SQL Script command string limitation

Does anybody know, if there is a command string size limitation in Firebird?
When executing a small "insert" script it works perfectly, but when the script has a lot of lines it returns the following errer: "Unexpected end of command - line X, column Y".
Interessting, the line and column number varies dependanding on the actual script size.
I'm using Firebird 2.5
Here is the executing script:
set term ^ ;
EXECUTE BLOCK AS BEGIN
insert into TABLE (COLUMNA) values (13);
...
insert into TABLE (COLUMNA) values (14);
END^
set term ; ^
Firebird 2.5 and earlier have a limitation of 64 kilobytes for the query text, for Firebird 3.0 this limit was increased to 10 MB when the new API is used. An EXECUTE BLOCK is one query, so it should not exceed 64 kilobyte.

Resources