Does the Database Toolbox support sql numeric ARRAY data types?
1 次查看(过去 30 天)
显示 更早的评论
Can anyone confirm inserting a matlab array into a database ARRAY field. I've not been able to do this with datainsert. I have done it by iterating over an sql query, but then I can't read it back again.
I have a matlab table that looks like this:
mpan meternumber date bin
_______________ ____________ ____________ _____________
'1012345738980' 'E12Z047967' '2016-01-17' [1x48 double]
'1012345874229' 'E11Z84795' '2016-01-14' [1x48 double]
'1012345874229' 'E11Z84795' '2016-01-15' [1x48 double]
'1012345874229' 'E11Z84795' '2016-01-16' [1x48 double]
'1012345874229' 'E11Z84795' '2016-01-17' [1x48 double]
'1012346434737' 'E11Z106965' '2016-01-14' [1x48 double]
'1012346434737' 'E11Z106965' '2016-01-15' [1x48 double]
'1012346434737' 'E11Z106965' '2016-01-16' [1x48 double]
'1012346434737' 'E11Z106965' '2016-01-17' [1x48 double]
'1012346453590' 'E11Z28462' '2016-01-17' [1x48 double]
An sql table defined like this:
CREATE TABLE consdata ( mpan VARCHAR(13), meternumber VARCHAR(12), date DATE, bin NUMERIC ARRAY[48], PRIMARY KEY (mpan, meternumber, date) );
And I get the following when I try to insert the data:
datainsert(conn,'consdata',data.Properties.VariableNames,data)
Error using database/DatabaseUtils/validateStruct (line 95)
Input structure, dataset or table incorrectly formatted. See help for details
Error in database.ODBCConnection/insert (line 118)
data = database.DatabaseUtils.validateStruct(data);
Error in database.ODBCConnection/datainsert (line 40)
insert( connect,tableName,fieldNames,data );
2 个评论
Tony L.
2016-1-29
I'm getting the same error when inserting dates and VARCHAR data into a table.
Inserting only VARCHAR data into a second table works.
Inserting only dates into a 1 column table (type DATE) gives me this error:
ODBC Driver Error: [Oracle][ODBC]Datetime field overflow.
My guess is that this issue is related to the date format. I'll come back if I find a solution.
the cyclist
2016-1-29
Only adding this comment so that I can easily see if there is any response. (My guess is that SQL arrays cannot be handled easily, but would love to be proved wrong.)
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!