sql 存储过程中得到用户名
到到当SESSION 用户名的方法很多如select user from dual; select username from user_users; SYS_CONTEXT(‘USERENV’,’CURRENT_USER’)等 等
SQL> conn test/test;
Connected.
SQL> create table test_pro(id int,
2 name varchar2(20),
3 insertdate date);
Table created.
SQL> create or replace procedure p_user
2 is
3 begin
4 insert into test_pro(id,name,insertdate) values(userenv(‘SESSIONID’),user,sysdate);
5 end;
6 /
Procedure created.
SQL> conn system/oracle
Connected.
SQL> create public synonym p_user for test.p_user;
Synonym created.
SQL> exec p_user;
PL/SQL procedure successfully completed.
SQL> select * from test.test_pro;
ID NAME INSERTDATE
———- —————————————- ————–
13000 SYSTEM 13-4月 -11
SQL> conn test/test
Connected.
SQL> exec p_user;
PL/SQL procedure successfully completed.
SQL> select * from test_pro;
ID NAME INSERTDATE
———- —————————————- ————–
13000 SYSTEM 13-4月 -11
13001 TEST 13-4月 -11
SQL>
下一篇: 在32位操作系统下SGA支持大内存
目前这篇文章有1条评论(Rss)评论关闭。