フィルターのクリア

Problem writing decimal number to Oracle DB number field

7 ビュー (過去 30 日間)
Christoph
Christoph 2016 年 3 月 16 日
回答済み: Christoph 2016 年 3 月 18 日
I am having problems writing numeric values to a database using the DB toolbox. Consider the following example:
conn = database.ODBCConnection('DB','user','pw');
arrColnames = {'IDENT','VAL'};
arrData = {'A' 1;'B' 0.1};
insert(conn,'MYTABLE',arrColnames,arrData);
Where the table is created on an Oracle database as:
CREATE TABLE MYTABLE
( "IDENT" VARCHAR2(4000 BYTE),
"VAL" NUMBER
);
Now the insert command works fine for integer values (entry 'A' in my array), but for numbers with after-comma digits I get the following error ('Ungültige Zahl' means invalid number):
Error using database.ODBCConnection/insert (line 264)
ODBC Driver Error: [Oracle][ODBC][Ora]ORA-01722: Ungültige Zahl

採用された回答

Christoph
Christoph 2016 年 3 月 18 日
I actually managed to solve it myself. For some reason, the database does not accept NUMBER-fields created without a scale (= number of after-comma digits). It works if you provide a scale explicitly:
CREATE TABLE MYTABLE
( "IDENT" VARCHAR2(4000 BYTE),
"VAL" NUMBER(*,5)
);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by