oracle,从视图访问成员函数
oracle, accessing to a member function from a view
首先,我有这个系统创建的对象:
create or replace
type type_client (
num int ,
username varchar(30),
balance int,
ta table_achat,
ref_admin ref type_admin,
member function get_prix_achat_total return int
);
我有一个 table 由系统创建的这个对象:
create table table_client of type_client
并且系统还创建了一个视图(它为每个用户提供了 select 他正确的行
来自 table_client):
create view one_line_client as
select * from table_client
where username = (select user from dual);
然后我给一个名为 c##client1
的用户 - 例如 - 访问此视图的权限。
我的问题是,用户 c##client1
可以访问 type_client
类型的所有数据
除了成员函数 ;
当我做
select balance from system.one_line_client;
或
select num from system.one_line_client;
然后我得到正确的结果。
但是当我这样做时
select olc.get_prix_achat_total() from system.one_line_client olc;
然后我得到错误:
ORA-00904: "OOO"."GET_PRIX_ACHAT_TOTAL": invalid identifier
00904. 00000 - "%s: invalid identifier"
星号并不代表一切,而是"all-column wildcard"。成员函数必须显式列为列表达式才能显示在视图中:
create view one_line_client as
select t.*,
t.get_prix_achat_total() as get_prix_achat_total
from table_client t
where username = (select user from dual);
该列表达式将间接调用该函数。从视图中选择时不能使用括号:
select olc.get_prix_achat_total from one_line_client olc;
首先,我有这个系统创建的对象:
create or replace
type type_client (
num int ,
username varchar(30),
balance int,
ta table_achat,
ref_admin ref type_admin,
member function get_prix_achat_total return int
);
我有一个 table 由系统创建的这个对象:
create table table_client of type_client
并且系统还创建了一个视图(它为每个用户提供了 select 他正确的行 来自 table_client):
create view one_line_client as
select * from table_client
where username = (select user from dual);
然后我给一个名为 c##client1
的用户 - 例如 - 访问此视图的权限。
我的问题是,用户 c##client1
可以访问 type_client
类型的所有数据
除了成员函数 ;
当我做
select balance from system.one_line_client;
或
select num from system.one_line_client;
然后我得到正确的结果。
但是当我这样做时
select olc.get_prix_achat_total() from system.one_line_client olc;
然后我得到错误:
ORA-00904: "OOO"."GET_PRIX_ACHAT_TOTAL": invalid identifier
00904. 00000 - "%s: invalid identifier"
星号并不代表一切,而是"all-column wildcard"。成员函数必须显式列为列表达式才能显示在视图中:
create view one_line_client as
select t.*,
t.get_prix_achat_total() as get_prix_achat_total
from table_client t
where username = (select user from dual);
该列表达式将间接调用该函数。从视图中选择时不能使用括号:
select olc.get_prix_achat_total from one_line_client olc;