c++ - 是否有比 Pro*C/C++ 更智能的 Oracle sql 预处理器?

标签 c++ sql c oracle oracle-pro-c

有人知道是否有 C/C++ 的预处理器与 Oracle 结合使用,可以让我编写类似于以下的 C 或 C++ 代码:

void populateTableList(GuiList* tableList) {

     for users in ( select table_name, 
                           owner, 
                           tablespace_name
                      from dba_tables) 
     {
         tableList -> addRow(
                         users.table_name, 
                         users.owner, 
                         users.tablespace_name);
     }
 }

我正在寻找的主要功能是

  • 选定值的准自动声明/定义(此处:users.table_nameusers.ownerusers.tablespace_name) 类似于PL/SQL for循环语句

  • 自动获取直到完成机制(无需明确调用stmt.fetch()过程或其他东西)和

  • 在编译时验证sql语句的正确性。

有这样的事情吗?

最佳答案

根据以下9、10、11页没有其他的C/C++ PRO*C/C++ 以外的“预编译器”。有一个C/C++编程 称为 OCI/OCCI 的语言接口(interface),但从技术上讲这不是预编译器

此页面声明“OCI 程序未预编译”:

http://www.orafaq.com/wiki/Oracle_Call_Interfaces

这些页面列出了可用的 C/C++ 编译器工具:

9I预编译页面: http://docs.oracle.com/html/A97297_01/ch4_comp.htm

This page lists PRO*C/C++, 
and the Non C precompilers: PRO*COBOL, PRO*FORTRAN,
SQL for ADA, the OCI

10G 预编译器页面:参见部件号 B25416-02 (此页面未列出任何其他 C/C++ 预编译器 已经列出)

9I 到 11 预编译器注释: https://blogs.oracle.com/db/entry/master_note_for_precompilers_oci_and_occi

(This page Does not list any other C/C++ precompilers not
already listed)

问汤姆 OCI/PRO*C 比较: http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:999630650601

This page shows an example that has an SQL statement with
invalid syntax being passed to OCI, through OCIStmtPrepare()
and the compile does not error.  This means that 
at the time of the OCI compile a complete syntax check
of the SQL statement is not done which is 
consistent with what I have seen.

本页声明“OCI 和预编译器支持 (..)”暗示 OCI 不进行预编译:

http://www.oracle.com/technetwork/database/features/oci/index.html

看起来您的代码中嵌入了 SQL。去检查 此代码在编译时的有效性将需要一个预编译器 可以访问数据字典(我知道 PRO*C 可以, 与您所拥有的不同的语法,但没有其他 ORACLE 上面列出的支持 C/C++ 的工具。

关于c++ - 是否有比 Pro*C/C++ 更智能的 Oracle sql 预处理器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9989543/

相关文章:

c - fflush 是如何工作的?

比较 WCHAR String 和 C 中的 Const Char?

c++ - 前向引用混淆

php - MySQL 获取查询中的行位置

c++ - 如何通过删除部分或全部#include 来清理预处理结果

php - mysql查询选择所有参数但限制每次出现的参数

MySQL 5.7 创建触发器语法错误?

C++ 纯虚多重继承?

c++ - Armadillo 矩阵转置

c++ - 如何判断点云的单位是什么?