If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Views vs Stored Procedures for updating etc..

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-06-06, 11:34
grooverinthesouth grooverinthesouth is offline
Registered User
 
Join Date: Mar 2006
Posts: 36
Views vs Stored Procedures for updating etc..

I have a number of relational tables in my schema.
I am developing a front-end for a DB and I would like to create a VIEW as a virtual table which maps directly to an application form which is used to capture the data.
This view would follow the form step-by-step so that inserting would be really easy and I would not have to join tables and select each column of info from each table that I needed to capture data with, instead just work with one virtual table that I can use one simple "insert into table" statement. It would in essence reflect the application form.

Q1: Can updating and inserting be done on VIEWS and is this a good idea?
Q2: Are stored procedures a better alternative?
Q3: I see that a lot of posts say that VIEWS are used to moderate security. How exactly does it achieve this.

Last edited by grooverinthesouth; 04-06-06 at 11:38.
Reply With Quote
  #2 (permalink)  
Old 04-06-06, 14:21
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
A1: Depending on your database engine and view construction, it may be possible to update a view. This makes no more sense to me than updating a SELECT.
A2: Stored procedures are a better alternative in my opinion.
A3: Views provide security in many ways. They allow the base tables to be left secured (no permissions need to be granted on the base tables). They allow the administrator to restrict which columns of which tables the user can see. Views also allow the developer/administrator to "bury" complex logic needed to get correct answers, while still making that logic easily accessible to end users.

-PatP
Reply With Quote
  #3 (permalink)  
Old 04-09-06, 03:13
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Views on joins of tables are never updatable.

An other alternative (in combination with a view) could be the use of triggers.
It really depends on the situation at hand which implementation is better.

Not only does a view allow resticting access to certain columns of a table, but also to certain rows of a table. Or even (when using GROUP BY in a view definition) to only summary reports of a table.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #4 (permalink)  
Old 04-09-06, 06:54
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
Originally Posted by Peter.Vanroose
Views on joins of tables are never updatable.
They are in some DBMSs. For example, Oracle allows the update of columns from "key-preserved" tables in join views. This means that you can update columns from a table whose primary key could also serve as a primary key for the view.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On