System.NotSupportedException:“Unknown column type Decimal(9, 4)”
Description
CLICKHOUSE FIELD IS DEFINED LIKE THIS:
PrintTicketLimitMoney Nullable(Decimal(9, 4)),
When i try to insert row:
foreach (DataRow row in table.Rows)
{
insertCommand.Parameters.Clear();
foreach (DataColumn column in table.Columns)
{
string paramName = $"{column.ColumnName}";
object columnValue = row[column.ColumnName];
insertCommand.Parameters.Add(paramName, columnValue ?? DBNull.Value);
}
insertCommand.ExecuteNonQuery();//get error
}
... System.NotSupportedException:“Unknown column type Decimal(9, 4)”
how to solve it.
Check the library version you use. Fixed length Decimal is supported since 1.1.15, since 1.2.3 they have improved precision (although still only fixed lengths are supported), support for arbitrary precision decimals came in 1.4.0 and after that they didn't change.
Plus, as far as I see you're doing inserts row-by-row, which is completely wrong for Clickhouse. Consider switching to bulk inserts.
And if you still encounted errors in most recent library versions, please provide table deifnition (CREATE command you used), and failing command text too.
Thanks your answer! for more table in my sqlserver, i read your readme.md about the bulk function like var command=connection.CreateCommand(); command.CommandText="INSERT INTO test (date,time,str,int) VALUES @bulk"; command.Parameters.Add(new ClickHouseParameter{ ParameterName="bulk", Value=list }); command.ExecuteNonQuery();
now i want to use like BulkInsert(DataTable, tableName), not want to define more class T.
how to solve it.
Plus, as far as I see you're doing inserts row-by-row, which is completely wrong for Clickhouse. Consider switching to bulk inserts.
And if you still encounted errors in most recent library versions, please provide table deifnition (CREATE command you used), and failing command text too.