【问题标题】:Is there a more intelligent sql-preprocessor for Oracle than Pro*C/C++?是否有比 Pro*C/C++ 更智能的 Oracle sql 预处理器?
【发布时间】:2012-04-03 08:18:09
【问题描述】:

有人知道是否有与 Oracle 结合使用的 C/C++ 预处理器,可以让我编写类似于以下的 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);
     }
 }

我正在寻找的主要功能是

  • 类似于PL/SQL for loop statement

  • 一种自动获取直到完成机制(没有显式调用stmt.fetch()过程或其他东西)和

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

有这种事吗?

【问题讨论】:

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


    【解决方案1】:

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

    此页面声明“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++ 支持的工具)。

    【讨论】:

    • 可能有 3rd 方工具,但我找不到任何工具,并且使用 3rd 方工具,您总是冒着 3rd 方工具不完全支持 ORACLE 特定 SQL 结构的风险 - 有PLSQL 有很多新的语法更改/添加,尤其是在 10/11
    猜你喜欢
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 2020-03-16
    • 2010-11-25
    • 2010-09-23
    • 1970-01-01
    相关资源
    最近更新 更多