如何在 delphi / interbase 中使用字符串作为 blob 进行插入查询
我想做一个查询插入:
INSERT INTO A_TABLE (BLOB_FIELD) VALUES(MY_BLOB_VAL)
但我在 delphi 中只有字符串值,例如:
procedure INSERT_BLOB_QUERY
var
query:String;
my_blob_val:String;
begin
my_blob_val := 'a blob string to be inserted';
query := 'INSERT INTO A_TABLE (BLOB_FIELD) VALUES(' + my_blob_val + ')';
// to execute a query....
end;
出现的问题是字符串到 blob 的转换。
那么如何在 interbase blob 字段中插入字符串???
I'd like to make a query insert:
INSERT INTO A_TABLE (BLOB_FIELD) VALUES(MY_BLOB_VAL)
but I have only string values in delphi for ex:
procedure INSERT_BLOB_QUERY
var
query:String;
my_blob_val:String;
begin
my_blob_val := 'a blob string to be inserted';
query := 'INSERT INTO A_TABLE (BLOB_FIELD) VALUES(' + my_blob_val + ')';
// to execute a query....
end;
The problem that occours is string to blob conversion.
So how to I insert a string in a interbase blob field???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样:
您的代码不起作用,因为您没有将字符串作为参数传递,而是将其作为查询的一部分传递。如果你这样做,你显然需要引用它:你这样做的方式 Interbase 会尝试将其解释为 SQL 命令,而不是解释为要插入数据库列中的文字字符串。
尽管如此,不要去引用。使用参数总是更好,更安全!
Like this:
Your code doesn't work because you're not passing the string as a parameter, you're passing it as part of the query. If you do that, you obviously need to QUOTE it: the way you're doing it Interbase will try to interpret it as SQL commands, not as a literal string to be inserted in a db column.
None the less, don't go for quoting. It's always better to use parameters, it's safer!