I'm trying to determine wether or not an employee is a member of a specific usergruop where the word 'contractor' is a part. All employees can be part of more than one usergroup, hence the error I get.
This is my select case statement:
SELECT CASE WHEN
(SELECT usergroup FROM usergr
WHERE usergroupnumber = (SELECT usergroupnumber FROM userlist
WHERE username='Carl'))
LIKE '%contractor%' THEN 1
ELSE 0
END FROM DUAL
Now it is this subquery which return more than 1 row because Carl is a member of more than 1 usergroup. How can i check if one of these usergroups has the 'contractor' in it.
UPDATE: Please let me provide you guys with some additional info on this.
This is to be used in a document management program. In this program I can create different attributes that is attached to all documents. And in these attributes I can place values based on select statements. So for example I have created an attribute which adds the projectnumber value to documents created in various Projects.
For my issue as described above I want an attribute that either hold the value 0 or 1. This will control wether or not a user can perform certain tasks in the program, when handling a file.
The select case statement I have written above 'almost' works. Because if you change 'Carl' with 'John' or 'Brian' I will get a correct value, because these are members of only one usergroup. But with 'Carl' or 'James' I get the error as they are part of more than one usergroup.
If you use the 'Example' I've given, I want the following result:
- When 'John' value = 0
- When 'Carl' value = 1
- When 'James' value = 1
- When 'Brian' value = 0
EXISTS
. - PM 77-1