Subject Re: [firebird-support] hiding some records
Author Milan Babuskov
Sergio H. Gonzalez wrote:
> Hello, I use FB2.1. Is there any way to hide (at database level) some records
> from a table. I have a quite simple scenario: selling articles marked as
> "inactive articles" And the use can choose wheter to see them or not. So far in
> every query I have for the articles table I do *WHERE ACTIVE = 'Y'* The problem
> is that in some forms I keep forgetting to add this clause and sometimes the
> inactive articles appear even if they are "hidden" in my app. So I was wandering
> if there is some way to filter that records in the database level. Something
> like adding *WHERE ACTIVE = 'Y'* to every select I perform to the article's
> table...

For stuff like this I use views and have a flag field in a separate
table so I can configure 'visibility' globally, or for each user. Example:

CREATE TABLE user_vision (
user_name char(8),
visible smallint -- 0 or 1

CREATE VIEW user_view (...)
SELECT t1...
FROM table1 t1
JOIN user_vision uv ON uv.user_name = current_user
WHERE = 'Y' or uv.visible = 1;

This way I can always select from USER_VIEW and not have to be careful
which table/view will I use.

Well, just this idea. I hope you find it useful.

Milan Babuskov