Undefined function 'fetch' for input arguments of type 'struct'
Ältere Kommentare anzeigen
Just got a computer refresh (replace) at work and now my scripts aren't working. Fails with an error of "Undefined function 'fetch' for input arguments of type 'struct'. I believe it's not actually the data type but system settings that are at fault since the same scripts worked on the previous computer.
Antworten (1)
Walter Roberson
am 1 Sep. 2017
1 Stimme
It sounds to me as if you do not have the database toolbox installed or licensed. Or perhaps the datafeed toolbox, or the financial timeseries toolbox; hard to say which without more information.
9 Kommentare
Steve Proctor
am 1 Sep. 2017
Steven Lord
am 1 Sep. 2017
Did you receive any warnings when you tried to execute the code that sets up the variables necessary to execute the actual fetch call?
How exactly are you trying to call fetch and how were the variables you pass into fetch created? In particular, is the first input to your call to fetch:
- a cursor, connection, or sqlquery object from Database Toolbox
- one of the connection objects available in Datafeed Toolbox
- a financial time series object from Financial Toolbox
- or something else (and if so, what?)
Walter Roberson
am 1 Sep. 2017
What shows up for
which -all fetch
? It is possible that you have the software installed but not the corresponding license.
Summer Al-Ali
am 9 Mär. 2019
Bearbeitet: Summer Al-Ali
am 9 Mär. 2019
I have the same problem.. I have a driver 'mysql-connector-java-5.1.12-bin.jar', I did everything to connect "MySQL JDBC " but still have this problem.
Here what I got.
>> which -all fetch
C:\Program Files\MATLAB\R2018a\toolbox\database\database\+database\+jdbc\@connection\fetch.m % database.jdbc.connection method
C:\Program Files\MATLAB\R2018a\toolbox\database\database\+database\+odbc\@connection\fetch.m % database.odbc.connection method
C:\Program Files\MATLAB\R2018a\toolbox\database\database\+database\+odbc\@cursor\fetch.m % database.odbc.cursor method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@datastream\fetch.m % datastream method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@factset\fetch.m % factset method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@fred\fetch.m % fred method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@haver\fetch.m % haver method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@kx\fetch.m % kx method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@rdth\fetch.m % rdth method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@reuters\fetch.m % reuters method
C:\Program Files\MATLAB\R2018a\toolbox\datafeed\datafeed\@statsllc\fetch.m % statsllc method
C:\Program Files\MATLAB\R2018a\toolbox\finance\ftseries\@fints\fetch.m % fints method
Walter Roberson
am 9 Mär. 2019
Could you show your fetch() call, and could you show how you build the variables that you pass to fetch() ?
Summer Al-Ali
am 13 Mär. 2019
I changed the connection to ODBC but stil have the same problem..
function User_insert_Callback(hObject, eventdata, handles)
global image_insert;
conn = database('FACE', 'root', '');
%Read data from database.
curs = exec(conn, ['SELECT user_t.User_id'...
' , user_t.Name'...
' , user_t.Phone_number'...
' , user_t.Email'...
' , user_t.Department'...
' , user_t.DT_ID'...
' FROM face_new.user_t ']);
curs = fetch(curs);
Walter Roberson
am 13 Mär. 2019
- Do not keep creating new database connections. Create a connection and store it.
- Avoid replacing the cursor with the result of fetch; it gets confusing about what you are referring to
- https://www.mathworks.com/help/database/ug/setdbprefs.html to configure what kind of object you get batch from fetch()
Steve Proctor
am 13 Mär. 2019
Walter Roberson
am 13 Mär. 2019
http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
You show a function User_insert_Callback. Is that the only function that needs to access the FACE database? Is the user only going to click on the function once, or only at comparatively large intervals compared to accessing other databases?
if ~isfield(handles, 'FACEconn')
handles.FACEconn = database('FACE', 'root', '');
guidata(hObject, handles);
end
curs = exec(handles.FACEconn, ['SELECT user_t.User_id'...
' , user_t.Name'...
' , user_t.Phone_number'...
' , user_t.Email'...
' , user_t.Department'...
' , user_t.DT_ID'...
' FROM face_new.user_t ']);
fetched_data = fetch(curs);
DataReturnFormat can include 'numeric', 'cell', 'structure', 'table', and 'timetable' . However some database types only support a subset of those.
Kategorien
Mehr zu MySQL Native Interface finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!