Results from DB are truncated
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am encountering a strange limitation in retreteiving the results from SQL database.
So I'm able to store 500000 characters (probably could save more but didn't had the need to test it) in DB without any issue. I can verify this by executing SELECT LEN(Value) FROM my_test_table.
The issue is when I try to read the data I get a table and length(data.Value{1}) is 3999, no metter if I use select, fetch, readall,...
Does anyone know how to remove this limit of 3999 charaters and read all the chars from that field in DB?
4 comentarios
Strider
el 24 de Mzo. de 2024
I tried to recreate your problem in sqlite, out of convenience, and I was unable to.
Try this example and see if it is giving you the same issue.
% ---- my additions
clearvars
dbfile = 'tstdb.db';
if isfile(dbfile); delete(dbfile); end
conn = sqlite(dbfile,'create');
tableName = "TestTable";
sq = sprintf("CREATE TABLE %s(Data char)",tableName);
% ---- my additions
execute(conn,sq)
% Create a long string
N = 500000;
longText = char(zeros(1, N) + 'A');
% write data to DB
inserQuery = sprintf("INSERT INTO [%s] (Data) VALUES ('%s')", tableName, longText);
execute(conn, inserQuery);
% Everything works just fine up till this point. If you check DB now you
% should see the correct entry in DB with all chars written. The issue
% starts when we want to retreive the data from DB
% read data from DB
query = sprintf("SELECT Data, length(Data) as LenInDb FROM [%s]", tableName);
res = fetch(conn, query);
% This doesn't work either
%res = select(conn, query);
% Display results
disp('Result from DB:');
numOfRows = numel(res.Data);
for i = 1:numOfRows
disp([strlength(res.Data{i}), res(i, "LenInDb").LenInDb]);
end
% Close connection
close(conn);
Respuestas (1)
James Anderson
el 7 de Ag. de 2024
I think the issue here is related to ODBC, I beleive if you switch to JDBC your problem will go away.
I can't particularly find any generic issues with ODBC and data truncation online, so I think this is a specific Matlab ODBC integration issue.
0 comentarios
Ver también
Categorías
Más información sobre Database Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!