|
|
发表于 2007/7/27 16:44:21
|
显示全部楼层
试试嵌入式SQL吧!
Example:
DECLARE
V1 VARCHAR2(100) := 'GUEST,ORACLE,SYSADMIN,SYS';
V2 VARCHAR2(100);
lv_sql_stmt VARCHAR(1000);
BEGIN
V1 := '(''' || V1 || ''')';
select replace(V1,',',''',''') INTO V2 from dual;
DBMS_OUTPUT.PUT_LINE(V2);
LV_SQL_STMT := 'SELECT USERNAME FROM ALL_USERS WHERE USERNAME IN ' || V2 || ' AND ROWNUM=1';
DBMS_OUTPUT.PUT_LINE(lv_sql_stmt);
EXECUTE IMMEDIATE lv_sql_stmt into V1;
DBMS_OUTPUT.PUT_LINE(V1);
END;
执行后OUTPUT,如下:
('GUEST','ORACLE','SYSADMIN','SYS')
SELECT USERNAME FROM ALL_USERS WHERE USERNAME IN ('GUEST','ORACLE','SYSADMIN','SYS') AND ROWNUM=1
SYS |
|