Oracle 11g SELF 成员过程不工作
我有以下内容:
create type customer as object (
id number, name varchar2(10), points number,
member procedure add_points(num_points number)
) not final;
/
create type body customer as
member procedure add_points(num_points number) is
begin
points := points + num_points;
commit;
end add_points;
end;
/
create table customer_table of customer;
/
insert into customer_table values (customer(123,'joe',10));
/
然后我这样做是一个匿名块:
declare
cust customer;
begin
select treat(value(c) as customer) into cust from customer_table c where id=123;
c.add_points(100);
end;
但没有任何反应 - 积分值仍为 10。
我错过了什么?如果我将我的成员程序设置为 update...set...commit
并传入点和给定的 id,它就可以工作。
谢谢。
I have the following:
create type customer as object (
id number, name varchar2(10), points number,
member procedure add_points(num_points number)
) not final;
/
create type body customer as
member procedure add_points(num_points number) is
begin
points := points + num_points;
commit;
end add_points;
end;
/
create table customer_table of customer;
/
insert into customer_table values (customer(123,'joe',10));
/
i then do this is an anonymous block:
declare
cust customer;
begin
select treat(value(c) as customer) into cust from customer_table c where id=123;
c.add_points(100);
end;
but nothing happens - the points value remains at 10.
What have i missed? If i make my member procedure an update...set...commit
and pass in the points and a given id, it works.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您发布的 PL/SQL 无效。我猜你是想发布这个:
第 5 行是“cust”而不是“c”?
如果是这样,您所做的只是更新变量 cust 中的点值,而不是表中的点值。您可以看到如下所示:
输出:
更新表中的数据确实需要 UPDATE 语句。
The PL/SQL you posted is invalid. I guess you meant to post this:
i.e. "cust" not "c" on line 5?
If so, all you have done there is updated the value of points in the variable cust, not in the table. You can see that like this:
Output:
To update the data in the table does indeed require an UPDATE statement.