Results from DB are truncated
    7 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
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 Kommentare
  Strider
 am 24 Mär. 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);
Antworten (1)
  James Anderson
 am 7 Aug. 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 Kommentare
Siehe auch
Kategorien
				Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
			
	Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!