Hope someone can help me...
I am trying to write a query that gets data from several tables. I have the query written and it works. I am including it here:
SELECT TO_CHAR(A.PONumPrefix, '000') || TO_CHAR(A.PONumMiddle, '000000') || TO_CHAR(A.PONumSuffix, '000') PONum, D.DeptName, P.VendorName, U.UserName FROM ApprovalTracking A, PO P, Department D, POUsers U WHERE A.Approved = ' ' AND A.PONumPrefix IN (SELECT DeptID FROM ORGCHART WHERE UserID = '" & gsLocalUser.UserID & "') AND U.UserID = A.AssignTo AND D.DeptID = A.PONumPrefix AND P.PONumPrefix = A.PONumPrefix AND P.PONumMiddle = A.PONumMiddle AND P.PONumSuffix = A.PONumSuffix ORDER BY P.CreationDate ASC, A.PONumMiddle ASC;
This query is supposed to get all pending approval records that are assigned to the department(s) the user belongs to. It works great. However, I need to restrict the select to pick only records that the local user is allowed to see.
Each user has a rank within a department that determines what they can and can't see. The users' rank can be different from department to department. I need to include something in the query that will check the department and rank level of the current record, and compare that to the local users' rank level for that department, and skip records that are higher ranking than the local user.
I'm starting to think this is going to require the use of a cursor, but I've never written with one before. Is there another way to do this? If not, how do I go about writing and using a cursor? I'm writing in Visual Basic 6 and using an Oracle 8 DB.
Thanks in advance
I am trying to write a query that gets data from several tables. I have the query written and it works. I am including it here:
SELECT TO_CHAR(A.PONumPrefix, '000') || TO_CHAR(A.PONumMiddle, '000000') || TO_CHAR(A.PONumSuffix, '000') PONum, D.DeptName, P.VendorName, U.UserName FROM ApprovalTracking A, PO P, Department D, POUsers U WHERE A.Approved = ' ' AND A.PONumPrefix IN (SELECT DeptID FROM ORGCHART WHERE UserID = '" & gsLocalUser.UserID & "') AND U.UserID = A.AssignTo AND D.DeptID = A.PONumPrefix AND P.PONumPrefix = A.PONumPrefix AND P.PONumMiddle = A.PONumMiddle AND P.PONumSuffix = A.PONumSuffix ORDER BY P.CreationDate ASC, A.PONumMiddle ASC;
This query is supposed to get all pending approval records that are assigned to the department(s) the user belongs to. It works great. However, I need to restrict the select to pick only records that the local user is allowed to see.
Each user has a rank within a department that determines what they can and can't see. The users' rank can be different from department to department. I need to include something in the query that will check the department and rank level of the current record, and compare that to the local users' rank level for that department, and skip records that are higher ranking than the local user.
I'm starting to think this is going to require the use of a cursor, but I've never written with one before. Is there another way to do this? If not, how do I go about writing and using a cursor? I'm writing in Visual Basic 6 and using an Oracle 8 DB.
Thanks in advance