ClickHouseClient icon indicating copy to clipboard operation
ClickHouseClient copied to clipboard

INSERT INTO VALUES error

Open Genuineh opened this issue 3 years ago • 1 comments

Hi, I got error when I run the code like

using var cnn = new ClickHouseConnection(settings.ToString());

await cnn.OpenAsync().ConfigureAwait(false);

using var cmd = cnn.CreateCommand("INSERT INTO cktest VALUES ({id:Int64}, {name:String})");

cmd.Parameters.AddWithValue("id", 1);
cmd.Parameters.AddWithValue("name", "name");

var res = await cmd.ExecuteNonQueryAsync().ConfigureAwait(false);

Error:

Octonica.ClickHouseClient.Exceptions.ClickHouseServerException : DB::Exception: Element of set in IN, VALUES or LIMIT or aggregate function parameter is not a constant expression (result column not found): CAST(__subquery_11347167823684683694_3925735668227058289, 'Int64'): While executing ValuesBlockInputFormat

I found a issues that said "Unfortunately, ClickHouse server doesn't support parameters in VALUES (...)."(https://github.com/Octonica/ClickHouseClient/issues/19#issuecomment-834318642) but I could get right result when i used clickhouse client cli, like

clickhouse-client --user=default --password --param_id=1 --param_name="name" -q "INSERT INTO default.cktest VALUES ({id:Int64}, {name:String})"

Are you sure the clickhouse not support parameters in VALUES?

Genuineh avatar Mar 19 '22 13:03 Genuineh

My Clickhouse server version is v22.2.3.5

Genuineh avatar Mar 19 '22 13:03 Genuineh