logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

Re: Updatable Cursors, CTID, and Views: msg#00155

db.postgresql.odbc

Subject: Re: Updatable Cursors, CTID, and Views

 


From: Mark Dexter [mailto:MDEXTER@xxxxxxxxxxxxxxxx]
Sent: 28 July 2004 17:10
To: Dave Page
Subject: RE: [ODBC] Updatable Cursors, CTID, and Views

Mr. Page:  Thanks for the response.  It appears that, if I include the CTID and OID columns in the view definition, I can successfully create updatable cursors without getting errors.  However, I then run into another apparent problem -- that normal views in PostgreSQL are not updatable.  I have started reading about using rules to create, in effect, views that can be updated.  However, it appears that using rules is somewhat complex and restrictive.
 
You are correct that they are not always the easiest things to use, however they are pretty powerful - check out http://www.postgresql.org/docs/7.4/static/rules-views.html and http://www.postgresql.org/docs/7.4/static/rules-update.html for some examples of what you can do. There was a guy working on creating simple view update rules automatically where possible, however this is not as easy as you might think at first glance. I don't know if he's still working on it.
 
If I may, I'd like to give you a quick idea of what I'm trying to do and perhaps get your opinion on whether this can be done in PostgreSQL.  In Oracle and SQL Server, I have created a series of views that are very simple subsets of underlying tables.  For example, a customer master table has customers for multiple companies (the first key column).  A single-company view is defined as "SELECT * FROM CUSTOMERS WHERE COMPANY_CODE = ff_company()", where ff_company() is a function that returns the current company being worked on.
 
In these other databases, single-table views are updatable as long as all of the table's columns are either defined in the view, are null-permisive, or have default constraints.  So these views can be treated exactly as if they are tables by our application.
 
My question is:  Is it possible to define a view or rule in PostgreSQL that would be updatable (insert, update, and delete) where it is a simple query of all columns for a selected subset of the rows of an underlying table? 
 
Yes, it is. There is a nice example of this in the article " Table defaults with View Rules " at http://www.varlena.com/varlena/GeneralBits/44.php
 
Thanks so very much for your help.  Mark Dexter (Seattle, WA, USA)
 
No problem.
 
Regards, Dave.
<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo