【问题标题】:Execute Oracle Query (DML) from Excel从 Excel 执行 Oracle 查询 (DML)
【发布时间】:2011-09-28 00:10:51
【问题描述】:

我可以将现有表/视图的结果链接到 Excel 电子表格(通过从 ODBC 向导的“选择数据库和表”窗口中选择表,但是我想改为执行原始查询。

我想根据单元格值生成一个查询(作为字符串)。然后,用户可以手动“刷新”数据表,将当前字符串发送到 Oracle 并返回结果。

有没有办法将原始查询 (DML) 的结果链接到 Excel 电子表格?

【问题讨论】:

    标签: sql oracle excel


    【解决方案1】:

    在我的博客herehere 中有一次(嗯,两次)关于此的内容。或许对你有帮助。

    雷内

    【讨论】:

    • 这正是我所需要的。谢谢!
    【解决方案2】:

    将数据库表链接到电子表格后,您可以使用宏来执行此操作。假设您的链接表从单元格 A1 开始:

    ' Build your query string - using whatever cell values you need
    sqlQuery = "select * from myTable"
    
    ' Get the cursor on the top left cell of the existing linked table
    Range("A1").Select
    
    ' Set the CommandText of that QueryTable to your new query and refresh it
    With Selection.QueryTable
        .CommandText = sqlQuery
        .Refresh BackgroundQuery:=False
    End With
    

    试试看……

    【讨论】:

      【解决方案3】:

      您必须设置查询,然后在查询中创建一个参数来限制结果集。通常,然后您让该查询填充一个新工作表。系统将提示您输入参数的值。将其设置为单元格引用,并选中复选框以自动重新查询该单元格是否更改。

      【讨论】:

        猜你喜欢
        • 2011-11-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-07
        • 1970-01-01
        • 2011-05-04
        • 2021-04-12
        相关资源
        最近更新 更多