利用 ODBC 转换功能

发布于 2024-07-27 18:38:15 字数 802 浏览 2 评论 0原文

朝向 SQLNativeSql() 函数的底部文档似乎表明 ODBC 驱动程序执行转换

它说:

以下是 SQLNativeSql 对于包含标量函数 CONVERT 的以下输入 SQL 字符串可能返回的示例。 假设数据源中 empid 列的类型为 INTEGER:
SELECT { fn CONVERT (empid, SQL_SMALLINT) } FROM 员工 
   

  Microsoft SQL Server 的驱动程序可能会返回以下翻译后的 SQL 字符串: 

  
从员工中选择转换(smallint,empid) 
   

  ORACLE 服务器的驱动程序可能会返回以下翻译后的 SQL 字符串: 

  
从员工中选择 to_number (empid) 
   

  Ingres 的驱动程序可能会返回以下翻译后的 SQL 字符串: 

  
从员工中选择 int2 (empid) 
   

这是真的吗? ODBC 能否真正转换 SQL 查询,以便理想情况下您的应用程序可以通过 ODBC 发送查询而在任何数据库系统上运行?

在实践中这真的有效吗?

在哪里可以找到“ODBC SQL 语法”列表?

Towards the bottom of the SQLNativeSql() function documentation it seems to be indicated that ODBC drivers perform translation.

It says:

The following are examples of what SQLNativeSql might return for the following input SQL string containing the scalar function CONVERT. Assume that the column empid is of type INTEGER in the data source:

SELECT { fn CONVERT (empid, SQL_SMALLINT) } FROM employee

A driver for Microsoft SQL Server might return the following translated SQL string:

SELECT convert (smallint, empid) FROM employee

A driver for ORACLE Server might return the following translated SQL string:

SELECT to_number (empid) FROM employee

A driver for Ingres might return the following translated SQL string:

SELECT int2 (empid) FROM employee

Is this really true? Can ODBC really translate SQL queries so that ideally, your application could run on any database system by sending queries through ODBC?

In practice does this actually work?

Where can you find the "ODBC SQL Syntax" listing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

尘曦 2024-08-03 18:38:15

翻译取决于驱动程序本身。 在许多情况下,它会返回您提供的确切 SQL 语句。 所以,没有 ODBC 并不能提供灵丹妙药。 您仍然需要担心正在运行查询的数据库。 如果使用多个数据库引擎,应用程序必须针对每个引擎定制查询(或使用在所有数据库引擎上运行的通用 SQL)。

The translation is dependent on the driver itself. In many cases, it will return the exact SQL statement that you give it. So, no ODBC does not provide a magic bullet. You still have to worry about the database you are running queries against. If using multiple database engines, the application has to tailor queries to each one (or use generic SQL that runs on all of them).

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