暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle SQL实用程序?

askTom 2018-02-14
149

问题描述

我们有一个第三方程序,运行我们的血液制品的收集/制造/分销。该程序使用Oracle数据库。第三方程序允许用户创建的SQL查询。我们目前正在升级到第三方程序的重大更改版本。新版本的第三方程序有一个200页面更改文档,其中包括许多表和字段名称更改。

我们的一个用户创建的SQL查询有一个 (复杂的我的经验水平) 10页的SQL脚本。当尝试将此用户创建的SQL查询与新程序版本一起使用时,出现Oracle 904错误。我了解这是因为新程序版本中的表字段名称与我的SQL脚本的某些部分不匹配。

我的问题是是否有某种实用程序可以帮助我轻松地识别SQL脚本中的所有表/字段Oracle 904错误?


专家解答

开箱即用,SQL Plus会给您错误的行号,例如

SQL> select *
  2  from dba_objects
  3  where owner = 'sys'
  4  and created > sysdate
  5  and temporary = 'y'
  6  and generate = 'y'
  7  and secondary = 'y'
  8  and namespace = 12
  9  and edition_name = 'y'
 10  and sharing = 'y';
and generate = 'y'
    *
ERROR at line 6:
ORA-00904: "GENERATE": invalid identifier


为了获得一个更 “全球化” 的想法,你可以

-在SQL上创建视图 (将失败)
-查看xxx_DEPENDENCIES,它将列出有效的对象
-将其与脚本中的对象进行比较

例如

SQL> create or replace force view bad_view as
  2  select *
  3  from dba_objects
  4  where owner = 'sys'
  5  and created > sysdate
  6  and temporary = 'y'
  7  and generate = 'y'
  8  and secondary = 'y'
  9  and namespace = 12
 10  and edition_name = 'y'
 11  and sharing = 'y';

Warning: View created with compilation errors.

SQL> select referenced_name
  2  from dba_dependencies
  3  where name = 'BAD_VIEW';

REFERENCED_NAME
----------------------------------------------------
DBA_OBJECTS

1 row selected.

SQL> create or replace force view bad_view as
  2  select *
  3  from dba_asd
  4  where owner = 'sys'
  5  and created > sysdate
  6  and temporary = 'y'
  7  and generate = 'y'
  8  and secondary = 'y'
  9  and namespace = 12
 10  and edition_name = 'y'
 11  and sharing = 'y';

Warning: View created with compilation errors.

SQL> select referenced_name
  2  from dba_dependencies
  3  where name = 'BAD_VIEW';

no rows selected



「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论