ODBC:如何处理布尔值?

发布于 2024-09-03 20:16:43 字数 148 浏览 2 评论 0原文

免责声明:我是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尛丟丟 2024-09-10 20:16:44

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.

他夏了夏天 2024-09-10 20:16:44

有 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.

温柔戏命师 2024-09-10 20:16:44

我相信这取决于实际的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文