![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
up to now, each user has rules to see workers on one department such as SELECT * from worker where DEPARTMENTNO=2 im doing this with query code in application, with lots of '..where DEPARTMENTNO='+inttostr(mydeptno) |
|
now im thinking of a technic for doing this in sqlserver side; is there a way like: DECLARE @DEPTNO int ---variable will be static for my session SET @DEPTNO=1 ---i will do this first for my connection session.. ----- and i will have a view like; SELECT ID,NAME from worker where DEPARTMENTNO=@DEPTNO |
#4
| |||
| |||
|
|
Which is not the way you should write it. If you are using .Net, you should write it as SELECT * FROM worker WHERE DEPARRTMENTNO = @depto And then pass the value of @depto in the SqlParameters collection. |
i just wanted to simplfy the situation.
#5
| |||
| |||
|
|
how is a session level temp table created? (standart "create table"?) |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
wat about: a real table with SESSIONID (int),DEPTNO (int). for each connection, connection will insert one row to that two columned real table, so view will be like "select w.ID,w.NAME from worker w,mysessions m where w.DEPARTMENTNO=m.DEPTNO and m.SESSIONID=GET_SESSION_ID (watever for getcurrentsessionid) or again for each connection, connection will insert one row to that two columned real table, view will be like "..m.DEPTNO=SOMEFUNCTIONTHATCALCULATESMYSESSIONDEP TNO()" |
|
or maybe i shall give up thinking about that |
#8
| |||
| |||
|
#9
| |||
| |||
|
|
after that i created a view like "select ID,NAME from worker where DEPTNO=GETMYSESSIONDEPTNO()" (GETMYSESSIONDEPTNO() is an sql function that returns related DEPTNO value in history table) |
![]() |
| Thread Tools | |
| Display Modes | |
| |