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

Run multiple sql statements in a transaction? #41

Open
Yash-Poddar opened this issue May 30, 2023 · 1 comment
Open

Run multiple sql statements in a transaction? #41

Yash-Poddar opened this issue May 30, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Yash-Poddar
Copy link

Hi,

I'm unable to use Begin; ... Commit; in ExecuteAsync(). I'm getting the following error -
" Snowflake.Client.Model.SnowflakeException : Query execution failed. Message: Multiple SQL statements in a single API call are not supported; use one API call per statement instead."

Is there a workaround or something so that I can use transaction?

@fixer-m
Copy link
Owner

fixer-m commented Jun 4, 2023

Hi,

Multiple statements feature was recently added in official connector and it's not supported yet in this project. One of the issues here is that they check DriverVersion field, for this feature it should be equal or greater than "2.0.18". The problem is that this library uses it's own versioning and sends something like "0.4.5.0".

Otherwise I think it would be enough to change MULTI_STATEMENT_COUNT to 0.
Something like this:

var result1 = await _snowflakeClient.ExecuteScalarAsync("ALTER SESSION SET MULTI_STATEMENT_COUNT = 0;");
var result2 = await _snowflakeClient.ExecuteScalarAsync<int>("SELECT 1; SELECT 2;");

I'm gonna work on this in next release.

@fixer-m fixer-m added the enhancement New feature or request label Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants