默认值,oracle sp 调用
我强加了一个 oracle SP,它在更新中不接受空参数。因此,如果我想将一个值设置回默认值 (''),它不会让我传入空字符串。是否有一个关键字可以使用,例如 default、null 等,oracle 会将其解释回为特定列指定的默认值?
I have an oralcle SP forced on me that will not accept an empty parameter in an update. So if I wanted to set a value back to the default of ('') it will not let me pass in the empty string. Is there a keyword you can use such as default, null, etc that oracle would interpret back to the default specified for a particular column?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有时事情就像你希望的那样简单。
首先,一个具有默认值的表...
接下来是一个更新默认列的过程...
...但它并没有像我们希望的那样工作:
所以,让我们尝试添加一个 DEFAULT 选项...
...瞧!
我在 11g 数据库上运行了这个示例。我不记得 Oracle 何时引入了对 DEFAULT 的确切支持,但已经有一段时间了(9i???)
编辑
评论确实令人沮丧。构建 PL/SQL API 的全部目的是让应用程序开发人员更容易与数据库交互。这包括在必要时足够明智地重写存储过程。用软件构建东西与将铸铁梁焊接在一起之间的最大区别在于,软件具有可塑性并且易于更改。特别是当更改不会改变现有过程的签名或行为时,就是这种情况。
Sometimes things are just as simple as you hope they might be.
First, a table with a default value ...
Next a procedure which updates the default column ...
... but which doesn't work as we would like:
So, let's try adding a DEFAULT option ...
... and lo!
I ran this example on an 11g database. I can't remember when Oracle introduced this exact support for DEFAULT, but it has been quite a while (9i???)
edit
The comments are really depressing. The entire point of building PL/SQL APIs is to make it easier for application developers to interact with the database. That includes being sensible enough to rewrite stored procedures when necessary. The big difference between building something out of software and, say, welding cast-iron girders together is that software is malleable and easy to change. Especially when the change doesn't alter the signature or behaviour of an existing procedure, which is the case here.
强加给你的程序:
如何使用:
我实际上没有编译,但我相信这是正确的语法。
The procedure that's been forced on you:
How to use:
I didn't actually compile, but I believe this is the correct syntax.