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

Example to update BLOB type column #580

Closed
nitishrana28 opened this issue Dec 26, 2016 · 4 comments
Closed

Example to update BLOB type column #580

nitishrana28 opened this issue Dec 26, 2016 · 4 comments

Comments

@nitishrana28
Copy link

Could you share an example for updating BLOB type. I could not find one.
Here is what I am doing :

// ImageData data type is Data
let statement = try db.prepare("Update SpecialityModule SET ImageData = ? where ServerId = ?")
try statement.run(module.ImageData as! Binding?, module.ServerId)

Error received on statement.run :

Could not cast value of type 'Foundation.Data' (0xd0fad8) to 'SQLite.Binding' (0x2bd6058).

@iNoles
Copy link

iNoles commented Dec 26, 2016

What happens if you remove as! Binding?

@nitishrana28
Copy link
Author

Complie time error of type casting.

@jberkel
Copy link
Collaborator

jberkel commented Dec 29, 2016

Data needs to be converted to Blob using datatypeValue:

try statement.run(module.ImageData.datatypeValue, module.ServerId)

Also see #142 (comment)

@nitishrana28
Copy link
Author

This saves the value as BLOB. So we can close this.

@jberkel jberkel closed this as completed Aug 24, 2021
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

3 participants