处理用户数据
<textarea cols="50" rows="15" name="code" class="c-sharp">CREATE OR REPLACE PROCEDURE users_process ( p_id in varchar, p_user_id in varchar, p_user_name in varchar, p_email in varchar, p_mobilenumber in varchar, p_department in varchar, p_company in varchar, rolename in varchar ) is row_id VARCHAR2(255); begin row_id:='0'; select id into row_id from users where user_name=p_user_name; if row_id!='0' THEN begin update users set user_id=p_user_id,email=p_email, mobilenumber=p_mobilenumber,department=p_department,company=p_company where user_name=p_user_name; usersrolebind(row_id,rolename); insert into temlog(type,rolename,username,time) values('update',rolename,p_user_name,to_char(sysdate, 'DD/MM/YYYY HH24:MI:SS')); end; end if; EXCEPTION WHEN NO_DATA_FOUND THEN begin insert into users(id,user_id,user_name,email,mobilenumber,department,company,password) values(p_id,p_user_id,p_user_name,p_email,p_mobilenumber,p_department,p_company,'11111111'); usersrolebind(p_id,rolename); insert into temlog(type,rolename,username,time) values('insert',rolename,p_user_name,to_char(sysdate, 'DD/MM/YYYY HH24:MI:SS')); end; end; commit;</textarea>
处理角色数据
<textarea cols="50" rows="15" name="code" class="c-sharp">CREATE OR REPLACE PROCEDURE usersrolebind ( p_user_id in varchar2, p_role_name in varchar2 ) is r_role_id VARCHAR2(255); g_role_id varchar2(255); begin r_role_id:='0'; g_role_id:='0'; select id into g_role_id from role where rolename=p_role_name; if g_role_id!='0' THEN begin select role_id into r_role_id from RONG_USERS_ROLEINFO rel left join ROLE r on REL.ROLE_ID=R.ID where R.ROLENAME=p_role_name and REL.USERS_ID=p_user_id; EXCEPTION WHEN NO_DATA_FOUND THEN begin insert into RONG_USERS_ROLEINFO(users_id,role_id) values(p_user_id,g_role_id); end; end; end if; EXCEPTION WHEN NO_DATA_FOUND THEN begin insert into temlog(type,rolename,username,time) values('role',p_role_name,p_user_id,to_char(sysdate, 'DD/MM/YYYY HH24:MI:SS')); end; end; commit; </textarea>