Consider an application for which different classes of users are granted diffeent levels of access to the underlying data. (Not too hard to imagine!)
Now, consider the case where one class of users is permitted to query the database based on some value of some field but another class cannot query based on this field.
One way to formulate this (at the application level) is as follows:
if (userClass = SuperUser) then
strField = " WHERE myField = 'foo'"
else
strField = ""
end if
Then, the SQL query can look like this:
"Select * From myTable" + strField
Alternatively, the value for myField can be passed to a StoredProcedure as a variable (which will be NULL for non-SuperUser's) and an IF clause (which selects between two different SQL statements) can be written in the StoredProcedure based on the value of the variable.
I find both of these approachs to be inelegant and ugly. There is almost certainly a cleaner way to do this, but I have yet to figure it out. Can you please offer a suggestion?
----
Gerry Roston
gerry@pairofdocs.net
Now, consider the case where one class of users is permitted to query the database based on some value of some field but another class cannot query based on this field.
One way to formulate this (at the application level) is as follows:
if (userClass = SuperUser) then
strField = " WHERE myField = 'foo'"
else
strField = ""
end if
Then, the SQL query can look like this:
"Select * From myTable" + strField
Alternatively, the value for myField can be passed to a StoredProcedure as a variable (which will be NULL for non-SuperUser's) and an IF clause (which selects between two different SQL statements) can be written in the StoredProcedure based on the value of the variable.
I find both of these approachs to be inelegant and ugly. There is almost certainly a cleaner way to do this, but I have yet to figure it out. Can you please offer a suggestion?
----
Gerry Roston
gerry@pairofdocs.net