accessing Long Text from matlab
1 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Guillaume
2017-5-11
I don't have any problem storing and retrieve LONGTEXT data from access, so you should explain what issues you've encountered.
However, note that I don't use (and don't have) the database toolbox to communicate with Access. The following works without any issues:
connection = actxserver('ADODB.connection'); %Use ADO to talk to Access
connection.Provider = 'Microsoft.ACE.OLEDB.12.0'; %Use Access engine
connection.Open([pwd, 'TestDb.accdb']); %Open existing database in local directory
connection.Execute('CREATE TABLE TestTableLT (Id COUNTER, Content LONGTEXT)'); %create table
connection.Execute(['INSERT INTO TestTableLT VALUES (1, "', char(randi(double('az'), 1, 1024)), '")']); %insert row with random 1024 characters
connection.Execute(['INSERT INTO TestTableLT VALUES (2, "', char(randi(double('az'), 1, 1024)), '")']); %insert row with random 1024 characters
recordset = connection.Execute('SELECT * FROM TestTableLT'); %retrieve rows
recordset.GetRows.' %get all rows (which are actually return as columns of a cell array, so transpose)
2 个评论
Guillaume
2017-5-12
To me, the problem appears to be that the length of the text multiplied by the number of rows uses too much memory to be retrieved all at once. Hence you run out of memory.
Have you tried limiting the number of rows fetched at once (with a TOP statement in your sql, with the MaxRows option of the exec statement, with the rowlimit of your fetch statement, or the batchsize of the fetch statement)?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!