Having used an Oracle DB for a while, I got used to using the Oracle DB Application Context to implement access restrictions. To simply put it, upon login a procedure is called that puts the user details into the Oracle Application context like so:
DBMS_SESSION.SET_CONTEXT('context_name', 'user_id', user_id);
Then access can be enforced by creating views that would look in the context to determine which rows can be seen by a user like so:
CREATE VIEW users_vw AS
SELECT *
FROM users
WHERE user_id = SYS_CONTEXT('context_name', 'user_id');
I have now moved away from Oracle and am using PostgreSQL for personal projects and SQL Server 2000 and 2008 at work. Can anyone tell me if there are corresponding capabilities that PostgreSQL or SQL Server offer?