Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.NotSupportedException:“Unknown column type Decimal(9, 4)” #161

Open
chenhunhun opened this issue Feb 29, 2024 · 3 comments
Open

Comments

@chenhunhun
Copy link

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.

@killwort
Copy link
Owner

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.

@killwort
Copy link
Owner

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.

@chenhunhun
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants