I don't know why am getting this error: Undefined function 'fetch' for input arguments of type 'struct'.
Mostrar comentarios más antiguos
The fetch command is well represented in matlab, but I don't know why it is difficult to use. Please I have being on this for a while, any assistance will be appreciated. Many thanks!
------------some code that produce error--------------------
conn = database(file_path, '', '', 'org.sqlite.JDBC', 'jdbc:sqlite:FS_NYC_data.db');
sqlquery = 'select * from dataset_TOKYO';
e=exec(conn,sqlquery); %,'cursorType','scrollable')
setdbprefs('DataReturnFormat','dataset')
curs = curs.fetch(e,50);
Respuestas (1)
Guillaume
el 5 de Mayo de 2016
I think the problem is that you've not fully understood what you are doing. Where does the curs variable come from in your example?
Note that in
e=exec(conn,sqlquery);
the e is a cursor. Obviously the later curs is another cursor (from another query).
Also note, that in matlab,
obj.function(xx, yy)
is the same as
function(obj, xx, yy)
so, your line
curs = curs.fetch(e,50);
is equivalent to
fetch(curs, e, 50)
you're passing two cursors to fetch, which doesn't know what to do with your second cursors. Hence the error (I think, I don't have the db toolbox).
Maybe you meant:
curs = e.fetch(50)
to import up to 50 rows.
2 comentarios
Guillaume
el 5 de Mayo de 2016
What is e in the code you've just posted. If it's a cursor, again, you're passing two cursors to fetch which is not going to work. It should be either:
fetch(curs, 50); %function notation
or
curs.fetch(50); %object notation
Also, what is the output of
whos curs e
Categorías
Más información sobre Import Data Programmatically en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!