23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

WITH CHECK OPTION<br />

CREATE VIEW<br />

Checks that the updated or inserted row satisfies the view definition. The row must be<br />

selectable using the view. The WITH CHECK OPTION clause is only allowed on an updatable<br />

view.<br />

Notes • A view is deletable if deleting rows from that view is allowed. For a view to be deletable,<br />

the view definition must satisfy the following conditions:<br />

– The first FROM clause contains only one table reference or one view reference.<br />

– There are no aggregate functions, DISTINCT clause, GROUP BY clause, or HAVING<br />

clause in the view definition.<br />

– If the first FROM clause contains a view reference, then the view referred to is<br />

deletable.<br />

• A view is updatable if updating rows from that view is allowed. For a view to be updatable,<br />

the view has to satisfy the following conditions:<br />

– The view is deletable (it satisfies all the previously specified conditions for<br />

deletability).<br />

– All the select expressions in the first SELECT clause of the view definition are simple<br />

column references.<br />

– If the first FROM clause contains a view reference, then the view referred to is<br />

updatable.<br />

• A view is insertable if inserting rows into that view is allowed. For a view to be insertable,<br />

the view has to satisfy the following conditions:<br />

– The view is updatable (it satisfies all the previously specified conditions for update<br />

ability).<br />

– If the first FROM clause contains a table reference, then all NOT NULL columns of the<br />

table are selected in the first SELECT clause of the view definition.<br />

– If the first FROM clause contains a view reference, then the view referred to is<br />

insertable.<br />

Example The following examples illustrate CREATE VIEW statements defined by query expressions:<br />

CREATE VIEW ne_customers AS<br />

SELECT name, address, city, state<br />

FROM customer<br />

WHERE state IN ( 'NH', 'MA', 'ME', 'RI', 'CT', 'VT' )<br />

WITH CHECK OPTION ;<br />

CREATE VIEW OrderCount (custnum, numorders) AS<br />

SELECT CustNum, COUNT(*)<br />

FROM Order<br />

GROUP BY CustNum;<br />

29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!