ODBC:如何处理布尔值?
免责声明:我是n00b。
ODBC好像不支持BOOLEAN类型?这是真的吗?
如果是这样,标准的拼凑方法是什么?
编辑:我在 Windows 上使用 ADO 和 Delphi 来写入数据,但使用 PHP 5 来读回数据。
Disclaimer: I am a n00b.
It seems like ODBC does not support a BOOLEAN type? Is this true?
If so, what's the standard kludgearound?
Edit: I am using ADO with Delphi on Windows to write the data, but PHP 5 to read it back.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SQL 本身传统上不支持布尔类型,因此 ODBC 只是反映了这一点。由于 ODBC 旨在提供跨数据库的可移植性,因此通常最好将数据库中的布尔值实现为标准类型之一,例如包含“Y”或“N”的 CHAR(1),而不是使用特定于供应商的类型。
SQL itself has traditionally not supported a boolean type, so ODBC is just reflecting this. As ODBC is intended to provide portability across databases, it is generally better to implement booleans in the database as one of the standard types, such as CHAR(1), containing either 'Y' or 'N', rather than use a vendor specific type.
有 SQL_C_BIT,但您需要查找给定驱动程序对每种 SQL 类型使用的内容。例如,MySQL 使用 SQL_C_CHAR对于布尔。
There's SQL_C_BIT, but you need to lookup what a given driver uses for each SQL type. For example, MySQL uses SQL_C_CHAR for bool.
我相信这取决于实际的 SQL Server 实现。如果您在 Windows 下执行此操作,您可以检查 ODBC 驱动程序/数据源设置 - 可能有诸如 Bool As Char 之类的选项。
I believe it depends on the actual SQL server implementation. You can check the ODBC driver/datasource settings, if you are doing it under Windows -- there might be options such as Bool As Char, or something.