Requirements
Ideally any library using MS Sql Server 2005 as a device. For example the
Sample.Pubs or Sample.Shipping libraries that come with Dataphor. The 
setup script contains an sql stored procedure that runs on S2005. The
sql procedure is not necessary for this example so you can use any db
device. You can also delete/comment out the sql procedure in the setup 
script. The D4 scripts were developed using Dataphor v2677. For best
results you should be running this (latest) version.

Please review the setup and drop scripts before using.

Review the SqlWindowExampleBackground.htm document for background on the
context of the example.

Review the screenshots.

Setup
Move/copy WindowExampleSetup.d4 and WindowExampleDrop.d4 to the Documents
directory of the library your using. Execute the WindowExampleSetup.d4 file
by going to the Dataphor Explorer and documents folder of your library and right
clicking WindowExampleSetup.d4 and selecting Execute. You can also Open 
WindowExampleSetup.d4 and execute it. It will create the sample data and all 
operators and other objects needed. You should have the reconcilation mode set
to 'command' to allow Dataphor to access the sample data Stocks table. You can
right click the library Devices name and choose Reconcilation Mode and
select Command. You can also reconcile the device manually using:
Reconcile(Name('YourLibraryName');
or
Reconcile(Name(GetDefaultDeviceName()));

Setup dependent objects
Move/copy the WindowExampleDependentsSetup.d4 script to create and populate
table WDepends. Follow the same procedure as described in Setup. This table
holds all objects used in the example and their dependencies. This table is
not necessary to run the demo but it is helpful in seeing just what objects
depend on other objects. Browse/select from table WDepends.

Running the demo
The sample data is table Stocks.
The demo is based on browsing the WindowExampleTableView view. Just go to the
Dataphor Explorer and under the library your using expand Views. Right click
on WindowExampleTableView and select Browse. The form will be presented.

Input fields:
Operator
This is the method used to obtain the cumulative aggregates, choose D4Apply or D4Window

Stocks for Window
This is the partition(s) (col Stock) over which the cumulative aggregates will be
obtained. Choose any comma delimited combination from 'IBM,MS,MySQL_AB,Oracle,Sybase'
or use the default 'All'.

Window definition
This is the group aggregate definition.
Example - 'ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING'
There are several definitions that are available for you to choose from or just
enter your own. The definition is parsed by the WList operator.
See the background write up. 

The Translation, From Value and To Value fields are read-only will be automatically
filled in based on the Window definition.

You can optionally add a comment.

The form is used to populate/update several tables.

WindowExampleTable 
This table appears in the upper part of the form and reflects the input data.

Window Summary Details
This appears in the 1st tab at the bottom of the window. It is summary
aggregate data based on the Operator/Window definition combination. It is 
stored in table D4WindowSummaryforForm.

Profile Summary Details 
This appears as the 2nd tab at the bottom of the form. It shows the number
of insert/deletes based on the Operator/Window definition. It is a 
measure of efficiency. This data is stored in the ProfileforForm table.

Dropping all the objects
Execute the WindowExampleDrop.d4 script to drop all the D4 objects created
in setup.

Dropping all object used in dependencies
Execute the WindowExampleDependentsDrop.d4 script to drop all operators
and tables involved in tracking dependencies.

Reviewing the setup script
When reviewing all the object code bear in mind the form based on the view
WindowExampleTableView is completely derived by Dataphor. This derivation
is based on all the objects involved in the view including tables and
references. Pay particular attention to 'tags' used on all objects 
including those used in operators. The information contained in these
tags is metadata and many tags provide information to the frontend server
which uses it to derive the form. Form derivation is one of the outstanding
features of Dataphor and is a cornerstone of rapid application development.
Of course the form can be 'customized' and feel free to do so. 
The script tries to touch on many different constructs. So hopefully you
will get a feel for what can be done with Dataphor.
Note that Dataphor strips all comments when it stores an object script.
You will find many comments on objects in the setup script.

Hopefully you will find this example helpful in exploring Dataphor.

Visit Dataphor @
www.alphora.com

More on Dataphor at my blog @
www.beyondsql.blogspot.com