PL/SQL 如何返回 ROW 中的所有属性
我不知道如何使用 RETURNING 子句返回所有属性,
我想要这样的内容:
DECLARE
v_user USER%ROWTYPE
BEGIN
INSERT INTO User
VALUES (1,'Bill','QWERTY')
RETURNING * INTO v_user;
END;
RETURNING * INTO
出现错误,如何替换 *
?
I don't know how I can return all attributes with the RETURNING clause
I want something like this:
DECLARE
v_user USER%ROWTYPE
BEGIN
INSERT INTO User
VALUES (1,'Bill','QWERTY')
RETURNING * INTO v_user;
END;
RETURNING * INTO
gets an error , how can I replace *
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我们能做类似的事情那就太好了,但是可惜:
我相信可能有对此功能的记录更改请求,因为我知道很多人都想要它。但目前我们所能做的就是对每一个专栏进行冗长的规范:
如果你有很多专栏,那就是坏消息了!
我怀疑其基本原理是,大多数表具有相对较少的派生列(分配给 ID 的序列、分配给 CREATED_DATE 的 sysdate 等),因此大多数值对于插入过程来说应该是已知的(或至少是已知的)。
编辑
我以为我已经说清楚了,但无论如何:是的,目前不可能在 RETURNING 子句中使用
*
或一些类似的非特定机制。It would be neat if we could do something like that but alas:
I believe there may be a logged change request for this feature, because I know lots of people want it. But for the moment all we can do is the long-winded specification of every column:
Bad news if you have a lot of columns!
I suspect the rationale is, most tables have relatively few derived columns (sequence assigned to an ID, sysdate assigned to a CREATED_DATE, etc) so most values should already be known (or at least knowable) to the inserting process.
edit
I thought I had made it clear, but anyway: yes currently it is impossible to use
*
or some similar unspecific mechanism in a RETURNING clause.到目前为止,我认为最好的解决方案可能是:
https://oracle- base.com/articles/misc/dml-returning-into-clause
不幸的是,仍然没有返回 * 或返回行之类的功能:) 但会很酷。
So far the best solution I believe could be:
https://oracle-base.com/articles/misc/dml-returning-into-clause
Unfortunately, still there is no such functionality as returning * or returning row :) but will be cool.