fetch returns a table full of cells for 'char' values

조회 수: 1 (최근 30일)
Sara Brunner
Sara Brunner 2020년 1월 26일
편집: Sara Brunner 2020년 2월 5일
I use fetch to get data from a MS Azure SQL Database into Matlab. My script worked when I last ran it - approximately 10 days ago. In the meanwhile the DB has been updated - the only change were changes in naming of tables and columns.
However, now I get a table where each field that should contain a character arrays, contains a cell. This makes it hard to work with the character arrays.
I tried to set the DB preferences, but it did not change the output.
setdbprefs('DataReturnFormat', 'table');
I also tried to put my simple SQL statement in a file and use runsqlscript instead of fetch - but I still got the char arrays in cells.
conn = database(datasource, username,password);
runsqlscript(conn,mySQLscript.sql)
This is the code I try to run (with some connetion details changed, of course)
conn = database(datasource, username,password);
sqlTest = 'select * from MyTableOfInterest'
conn = database('MyDB','DB_Reader_user','MyPassword','Vendor','MICROSOFT SQL SERVER','Server','myProjectServer.database.windows.net','PortNumber',1433,'AuthType','Server');
dataDB_ids = fetch(conn,sqlTest);
close(conn)
The result looks like this:
Matlab_Table_troubleShooting.JPG
I would like to have is the above picture without the curley brackets.
I know I can do that with using for-loops and changing field per field, but there must be a smarter solution. (Especially since I think the the result looked fine last time I ran the script).
Technical details:
MATLAB Version: 9.7.0.1247435 (R2019b) Update 2
Database Toolbox Version 9.2 (R2019b)
Best regards, Sara

답변 (1개)

Harsha Priya Daggubati
Harsha Priya Daggubati 2020년 1월 31일
  댓글 수: 1
Sara Brunner
Sara Brunner 2020년 2월 5일
편집: Sara Brunner 2020년 2월 5일
Thanks Harsha,
I set the sqlimportoptions VariableTypes to 'char', but I still get {'char'} as a result in my table.
I guess it has something to do with fields containing NULL even if I do not have any in my selection.
However, I implemented a workaround (with for loops) which decreases the performance, but it works.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by