Consider the following table:
create table PROJ
( PROJ_ID varchar(12)
, PROJ_NAME varvhar(30)
, ORG_ID varchar(12)
)
A simiplified version of our stored procedure would resemble this:
create procedure show_projects
as
select * from PROJ
return
What I want is a view that would only select those rows from the PROJ
table based on my user_name and containing only those ORG_ID's I am
allowed to see. The view for my username might do something like this:
create view my_view
as
select *
from PROJ
where ORG_ID in ("1.023","1.024")
Obviously, something more flexible that would work with any username
would be required. If such a view existed, all I would have to do is
replace all references to PROJ by that view's name. The change is
trivial:
create procedure show_projects
as
select * from my_view
return
Since you can create any number of views on the same table, creating views is done with a separate link called, Create Views. You simply select the appropriate table and columns, give the view a name, and click a button to automatically generate your view.
The third link is called Modify Procedures, which can be used to automatically replace table names with view names. You simply select which table, procedure and view, and click the Modify button.
The last link on the main screen is called User Administration. This is where you determine which users can see which rows in your tables. Once the view is created, you can add or drop permissions at anytime. You do not need to recreate the view unless you add or drop columns from the profile.
create table dataprotects
( uid int not null -- user_id.
, id int not null -- object_id.
, colid int not null -- column_id.
, value varchar(30) not null -- "1.023"
)
The limit of 30 characters should be adequate for most applications. A
larger value would require modification of the stored procedure, but
also probably means the number of possible values in your table are
too great for efficently using this mechanism. Values in your tables
which exceed this length are automatically truncated.
Checked checkboxes means this table already exists in your profile. You would still click this to add or delete columns.
Once you have selected a table name, the left margin displays a list of all columns in that table. Again, simply select the columns you wish to modify.
Checked checkboxes means this column already exists in your profile. Unchecking a checkbox causes the column and all data to be removed from the profile, and checking a checkbox causes that column to be added to the profile. In the former case, an alert is displayed confirming that you actually want to delete this column.
Once you have selected a table name, the left margin displays a list of all columns that were specified when you defined your profile. Check all column names that you want to use to create your view.
Following the column names are one or more radio buttons. The first radio button says to prompt you for the view name. The remaining radio buttons (if any) correspond to views you have already created. You can select one of those to recreate a view.
Click the button and your view is created.
You don't need to worry that you might accidently drop an object. The procedure won't let you drop any object that is not a view, nor any views that were not created by this procedure.
Clicking this link displays a list of all tables that have been defined in your profile. Selet the table name you are interested in.
One you have selected a table name, the left margin displays a list of only those procedures and views which reference this table. Simply select the procedure you are interested in, the view you wish to use, and click the Modify button to update your procedure.
If for some reason the procedure fails to compile, a JavaScript alert will be displayed. You should pay close attention to this alert because it means your procedure is now gone. It's time to panic!
When you click this link, the left margin is replaced by a list of all usernames in your database and the right margin is replaced by a list of all possible values from all tables and columns that you defined in your profile.
You must select a username from the left margin before you can begin defining permissions. The checkbox next to each username will be checked if the username you selected has the exact identical permission. You can also click the checkbox next to any username to copy the same permissions from the username you previously selected.
Once you have selected a username, simply check or uncheck the appropriate values from each column and table. Use the "Grant All" button if they can view all values. Use the "Revoke All" button to revoke all permissions on a particular column.
Note: The "Grant All" button only grants permissions to those values that are currently in your database. If new values are added, permission is not granted to that row.
Here are the steps:
Work around: Wait for both frames to load before selecting a username.
Using the browser's Go menu item or Back button to return to Projector will sometimes cause a JavaScript error.
Work around: Click the Reload button.