一个关于游标与用户名的问题,在线等!!!!
suser varchar2(100);
select sys_context( 'userenv ', 'current_user ')
into suser
from dual;
declare
cursor YSSQL is
SELECT Bgt_Set_Code, Dim_Type, Dim_Type_Name, Dim_ID
FROM sUser.Tbl_Pla_DimType
Where Dim_ID NOT IN
(SELECT OBJECT_ID
FROM pla.HSP_OBJECT
WHERE (OBJECT_TYPE =
(SELECT OBJECT_TYPE
FROM pla.HSP_OBJECT_TYPE
WHERE (TYPE_NAME = 'Dimension '))) AND (OBJECT_ID = 33 OR
LENGTH(OBJECT_ID) > 4)) And (Bgt_Set_Code = RTRIM(sBgt_Set_Code))
ORDER BY DIM_TYPE;
begin
Open YSSQL;
for cDimType in YSSQL loop
end loop;
end;
suser 是定义的一个变量,通过系统函数得到当前用户名.但是编译时总是提示找不到表或视图?如何解决?
------解决方案-------------------- "SELECT Bgt_Set_Code, Dim_Type, Dim_Type_Name, Dim_ID
FROM sUser.Tbl_Pla_DimType "
觉得你这个用法不妥,suser是个变量,你这里应该是要用一个用户,
写成这样试试:
"SELECT Bgt_Set_Code, Dim_Type, Dim_Type_Name, Dim_ID
FROM " || sUser || ".Tbl_Pla_DimType "