我有这样一张桌子:
Id | GroupId | Category
------------------------
1 | 101 | A
2 | 101 | B
3 | 101 | C
4 | 103 | B
5 | 103 | D
6 | 103 | A
........................
Run Code Online (Sandbox Code Playgroud)
我需要GroupId随机选择其中一个.为此,我使用了以下PL/SQL代码块:
declare v_group_count number;
v_group_id number;
begin
select count(distinct GroupId) into v_group_count from MyTable;
SELECT GroupId into v_group_id FROM
(
SELECT GroupId, ROWNUM RN FROM
(SELECT DISTINCT GroupId FROM MyTable)
)
WHERE RN=Round(dbms_random.value(1, v_group_count));
end;
Run Code Online (Sandbox Code Playgroud)
因为我舍入了随机值,所以它将是一个整数值,WHERE RN=Round(dbms_random.value(1, …
我是PL/SQL语言的新手.我看到有两个函数PL/SQL:UPPER和NLS_UPPER.他们都做同样的事情.我想知道这些功能之间的区别.谢谢
我有一个ASP.NET应用程序,平均可以同时由120-140个用户访问.我使用Session来获取和设置用户特定信息.为了方便起见,我有一个静态的类调用CurrentSession,它有一个名为UserInfo:
public static class CurrentSession{
public static UserInfo{
get{return HttpContext.Current.Session["userInfo"]!=null?(UserInfo)HttpContext.Current.Session["userInfo"]:null;}
set{HttpContext.Current.Session["userInfo"]=value;}
}
//And other properties
}
Run Code Online (Sandbox Code Playgroud)
每当我需要当前用户的信息时,我就会这样做:
CurrentSession.UserInfo;
Run Code Online (Sandbox Code Playgroud)
最近我遇到了检索错误用户信息的情况.我的方法中是否存在可能导致Session冲突的问题?