13.01.2013 Views

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2: Initial Programming Considerations<br />

MS <strong>SQL</strong> <strong>Server</strong> data source views<br />

MS <strong>SQL</strong> <strong>Server</strong> data source schema objects include views. A view is a presentation of<br />

data in one or more tables. Views appear as tables, not as views, in the <strong>Data</strong><br />

Dictionary’s table list <strong>for</strong> the schema holder. In addition, the schema holder contains no<br />

unique index in<strong>for</strong>mation <strong>for</strong> views. Because views do not have unique indexes, you<br />

cannot modify any of the data that a view contains; however, you can access a view<br />

with the FOR EACH, FIND NEXT, and GET NEXT <strong>OpenEdge</strong> statements. Furthermore,<br />

because views do not have index definitions, the <strong>Data</strong><strong>Server</strong> cannot reposition the<br />

cursor to retrieve individual records. Thus, you must be sure to get all of the data that<br />

you need in a single database request.<br />

The following ABL code example retrieves data from a view:<br />

OPEN QUERY query-name FOR EACH view-name.<br />

REPEAT:<br />

GET NEXT query-name.<br />

DISPLAY view-name.<br />

. . .<br />

END.<br />

If a view has a unique combination of columns, you can simulate a unique index using<br />

the <strong>Data</strong> Dictionary. You can then access a view that has a simulated unique index just<br />

as you do a table; that is, you can scroll backward and <strong>for</strong>ward, and update, create, and<br />

delete data. See the “Modifying field-level in<strong>for</strong>mation” section on page 309 <strong>for</strong><br />

in<strong>for</strong>mation on how to do this.<br />

Some views are the results of joins and contain data from more than one table. You<br />

can also provide unique index in<strong>for</strong>mation <strong>for</strong> these views if they have a unique<br />

combination of columns. You can then scroll backward and <strong>for</strong>ward, but the MS <strong>SQL</strong><br />

<strong>Server</strong> data source does not allow you to create or delete data in a multi-table view.<br />

You can, however, update data in some views.<br />

The <strong>Data</strong><strong>Server</strong> does not support access to columns in views that are the results of<br />

aggregates or computations unless the calculated column has a name associated with<br />

it. You assign a specific name to a calculated column when you define a data source<br />

view. For example, the following <strong>SQL</strong> statement names a computed column in a view<br />

definition:<br />

create view view-name as select cc = count(cust_num) from customer<br />

You can also access those views by using the RUN STORED–PROC send–sql–statement<br />

option to send a <strong>SQL</strong> statement to select the data from the view. In this case, you can<br />

access the view without adding index definitions <strong>for</strong> the view to the schema holder.<br />

Although the schema holder contains your views, the <strong>Data</strong> Dictionary’s <strong>SQL</strong> View<br />

Report does not list them, nor can you access them through the PRO/<strong>SQL</strong> menu<br />

functions.<br />

68 <strong>OpenEdge</strong> <strong>Data</strong> <strong>Management</strong>: <strong>Data</strong><strong>Server</strong> <strong>for</strong> <strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong>

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

Saved successfully!

Ooh no, something went wrong!