Article View: pl.comp.bazy-danych
Article #183237Re: MSSQL - problem z widokiem
From: Przemysław Rachwał
Date: Thu, 02 Jul 2009 06:38
Date: Thu, 02 Jul 2009 06:38
61 lines
3003 bytes
3003 bytes
Adam wrote: > Mam 3 tabele magazynowe: Towar (TW), Ceny (CN), Stany (SM) > > W Ceny mam różne ceny mnie interesują ceny zakupu i sprzedaży > (rozróżniane po polu typ) > W Stany mam stany magazynowe towarów dla różnych magazynów > > Chcę mieć widok który mogę aktualizować: > twId, twName, cenaZ, cenaS, stanSuma > > Dla stanów wykonałem widok stanów magazynowych vSM_Sum poprzez grupowanie: > twId, Sum(stan) -> wyciągam sumę stanów na wszystkich magazynach > > > Gdy połączę ze sobą tabele TW, CN i widok vSM_Sum : > > SELECT TW.id, TW.name, CN.type, CN.price, vSM_Sum.state > FROM dbo.TW INNER JOIN > dbo.CN ON dbo.TW.id = dbo.CN.twId INNER JOIN > dbo.vSM_Sum ON dbo.TW.id = dbo.vSM_Sum.twId > > Wynik dla Select jest OK ale próba edycji tego kończy się błędem: > "Niedostateczne informacje o kolumnie klucza w celu aktualizacji i > odświeżenia" > > Co robię nie tak? nie zrobisz takiego widoku z funkcją agregującą czytaj dokumentację tam o tym piszą Updatable Views You can modify the data of an underlying base table through a view, as long as the following conditions are true: Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one base table. The columns being modified in the view must directly reference the underlying data in the table columns. The columns cannot be derived in any other way, such as through the following: An aggregate function: AVG, COUNT, SUM, MIN, MAX, GROUPING, STDEV, STDEVP, VAR, and VARP. A computation. The column cannot be computed from an expression that uses other columns. Columns that are formed by using the set operators UNION, UNION ALL, CROSSJOIN, EXCEPT, and INTERSECT amount to a computation and are also not updatable. The columns being modified are not affected by GROUP BY, HAVING, or DISTINCT clauses. TOP is not used anywhere in the select_statement of the view together with the WITH CHECK OPTION clause. -- Przemek "Non sunt multiplicanda entia sine necessitate" http://vbamania.blogspot.com
Technical Details
Message-ID:
<h2hkm8$aum$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<h2hhl9$mp6$1@news.onet.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Przemysław Rachwał <przemyslaw.rachwal@gmail.com> Newsgroups: pl.comp.bazy-danych Subject: Re: MSSQL - problem z widokiem Date: Thu, 02 Jul 2009 08:38:59 +0200 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 61 Message-ID: <h2hkm8$aum$1@inews.gazeta.pl> References: <h2hhl9$mp6$1@news.onet.pl> NNTP-Posting-Host: 91.123.160.178 Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1246516744 11222 91.123.160.178 (2 Jul 2009 06:39:04 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Thu, 2 Jul 2009 06:39:04 +0000 (UTC) X-User: prachwal In-Reply-To: <h2hhl9$mp6$1@news.onet.pl> User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit