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

Create successful ePaper yourself

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

Initial Programming Considerations<br />

2–14<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 the <strong>Data</strong><br />

Dictionary. You can then access a view that has a simulated unique index just as you do a table;<br />

that is, you can scroll backward and <strong>for</strong>ward, and update, create, and delete data. See the<br />

“Modifying field-level in<strong>for</strong>mation” section on page 7–33 <strong>for</strong> 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 can also<br />

provide unique index in<strong>for</strong>mation <strong>for</strong> these views if they have a unique combination of columns.<br />

You can then scroll backward and <strong>for</strong>ward, but the MS <strong>SQL</strong> <strong>Server</strong> data source does not allow<br />

you to create or delete data in a multi-table view. 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 aggregates<br />

or computations unless the calculated column has a name associated with it. You assign a<br />

specific name to a calculated column when you define a data source view. For example, the<br />

following <strong>SQL</strong> statement names a computed column in a view 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 option to<br />

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

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 Report<br />

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

Triggers<br />

Triggers are code that an application associates with a data source object and an action. For<br />

example, writing a record might cause code associated with that object or action to execute. The<br />

<strong>Data</strong><strong>Server</strong> allows an application to execute triggers <strong>for</strong> both <strong>OpenEdge</strong> databases (including<br />

the schema holder) and MS <strong>SQL</strong> <strong>Server</strong> data sources. In an application that executes both types,<br />

the <strong>OpenEdge</strong> trigger (CREATE, FIND, UPDATE, DELETE) executes first. If processing an <strong>OpenEdge</strong><br />

trigger results in a data source request, the <strong>Data</strong><strong>Server</strong> passes the request to the MS <strong>SQL</strong> <strong>Server</strong><br />

data source and the operation (INSERT, UPDATE, DELETE) executes.<br />

Triggers <strong>for</strong> <strong>OpenEdge</strong> databases and MS <strong>SQL</strong> <strong>Server</strong> data sources are independent of each<br />

other. A data source trigger that rolls back does not affect <strong>OpenEdge</strong> triggers. Defining a trigger<br />

in <strong>OpenEdge</strong> does not create a data source trigger definition. An <strong>OpenEdge</strong> trigger that rolls<br />

back does so independently of the data source’s transaction scope. Note, however, that although<br />

triggers <strong>for</strong> <strong>OpenEdge</strong> databases and MS <strong>SQL</strong> <strong>Server</strong> data sources are independent, they might<br />

affect each other based on the kind of transaction your application is executing. For example,<br />

ensure that triggers running in both <strong>OpenEdge</strong> and at the data source do not dead lock on the<br />

same record access.

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

Saved successfully!

Ooh no, something went wrong!