如何最小化物理 DDL 更改和 PL/SQL 更改之间的耦合/依赖关系?
我们在 Oracle 表定义 (DDL) 和 PL/SQL 脚本之一中遇到了一个特定问题。
问题是,表中发生了变化,从 varchar(20)
更改为 varchar(30)
,但是这一变化并没有在我们的一个表中得到认真反映。 PL/SQL 脚本使用的数据仍然是 varchar(20)
,导致在我们的一项回归测试期间出现 ORA-06502: PL/SQL: numeric or value error
错误。
这里想请教Oracle和数据库专家,你们过去是否遇到过这样的场景,表DDL发生了变化,而没有反映到PL/SQL中,你们是如何处理这个差距的。
我知道一种简单的方法是某种形式的强制执行或文书工作,但是是否会出现更美观或更优雅的解决方案,即外键避免插入/更新/删除异常的工作方式?
谨致谢意!
We ran into a particular issue with our Oracle table definition (DDL) and in one of our PL/SQL scripts.
The issue is, there was a change in the table, changing from varchar(20)
to varchar(30)
, this change however, was not diligently reflected in one of our PL/SQL scripts consuming data, which was still varchar(20)
, causing a ORA-06502: PL/SQL: numeric or value error
error during one of our regression tests.
I would like to seek advise from Oracle and database experts here, whether you have encountered such scenarios in the past, whereby there were changes to table DDL, and were not reflected in the PL/SQL and how you deal with this gap.
I know one easy way would be some form of enforcement or paperwork, but would there happen be more beautiful or elegant solution, i.e. the way foreign keys work to avoid insert/update/delete anomaly?
With thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于初学者,您应该始终根据表中的列定义将变量声明为 TYPE:
即,而不是:
使用:
这样,当您的基表更改时,您的声明仍然有效。
您还可以将过程参数声明为类型:
For starters, you should always declare your variables as TYPEs based on the column definitions in your tables:
I.e., instead of:
Use:
That way, when your base table changes, your declaration is still valid.
You can also declare your procedural parameters as types as well: