Why does sqlwrite function not support BINARY_FLOAT and BINARY_DOUBLE datatypes provided by Oracle
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 6 Apr. 2018
Beantwortet: MathWorks Support Team
am 18 Apr. 2018
When sqlwrite function is used to insert BINARY_FLOAT or BINARY_DOUBLE datatypes as given in following code snippet
>>sqlquery = ['CREATE TABLE MyOracleTable(myBinaryFloatValue BINARY_FLOAT)'];
>>exec(conn,sqlquery); % "conn" is the Database Connection object
>>myMLTable = table(1,'VariableNames',{'myBinaryFloatValue'});
>>sqlwrite(conn,'MyOracleTable',myMLTable);
MATLAB throws following error:
Error using database.jdbc.connection/sqlwrite (line 172)
JDBC JDBC/ODBC Error: java.lang.Double cannot be cast to oracle.sql.BINARY_FLOAT.
Akzeptierte Antwort
MathWorks Support Team
am 6 Apr. 2018
Converting MATLAB numeric datatypes to BINARY_FLOAT or BINARY_DOUBLE is not currently supported by "sqlwrite", mainly because these data types are not part of the ANSI-supported SQL types.
As a workaround, directly convert the data to BINARY_FLOAT before passing it to "sqlwrite" as follows:
>>myMLTable = table([oracle.sql.BINARY_FLOAT(3);oracle.sql.BINARY_FLOAT(4)] ,'VariableNames',{'myBinaryFloatValue'});
>>sqlwrite(conn,'MyOracleTable',myMLTable );
Please note that for this workaround to work, the table 'MyOracleTable' should already exist in the database.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Reporting and Database Access finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!