Plsql Oracle 11g自成员过程不工作

Plsql Oracle 11g自成员过程不工作,plsql,oracle11g,Plsql,Oracle11g,我有以下资料: 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 := po

我有以下资料:

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,它就会工作


谢谢

您发布的PL/SQL无效。我猜你是想发这个:

declare
  cust customer;
begin
  select treat(value(c) as customer) into cust from customer_table c where id=123;
  cust.add_points(100);
end;
i、 第5行的“客户”不是“c”

如果是这样的话,您在那里所做的只是更新变量cust中的点的值,而不是表中的点。你可以这样看:

declare
  cust customer;
begin
  select treat(value(c) as customer) into cust from customer_table c where id=123;
  cust.add_points(100);
  dbms_output.put_line(cust.points);
end;
输出:

110

更新表中的数据确实需要更新声明。

我从您之前的一个问题中了解到,您正在参加某种培训课程。不幸的是,他们似乎在培训你一些相当神秘和毫无意义的甲骨文功能!