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

SNOW-978294 provide usage example on how to insert data into a VARIANT column #824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,21 @@ using (IDbConnection conn = new SnowflakeDbConnection())
}
```

Writing to `VARIANT` column with bind variable
----------------------------------------------
You can use bind variables together with `VARIANT` datatype column. For example, to insert data:
```cs
cmd.CommandText = "insert into table (id, data) select :id, parse_json(:data)"
```
then reference the `SFDataType` for the named parameter, `p2` in this example:
```cs
p2.SFDataType = SFDataType.TEXT
```
As an alternative, you can use an approach like:
```cs
var p2 = new SnowflakeDbParameter("data", SFDataType.TEXT) { Value = jsonStr };
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing binding with named parameters is not supported in multi statement queries.
Can you please make a not on this @sfc-gh-dszmolka and we will merge this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close the Connection
--------------------

Expand Down
Loading