™ DEV-5: Using ProDataSets in OpenEdge 10

Download Report

Transcript ™ DEV-5: Using ProDataSets in OpenEdge 10

DEV-5: Using ProDataSets™
in OpenEdge® 10
Cheryl LaBarge
Product Readiness
Agenda
ProDataSets
 Evolution of data access
 Reasons to use ProDataSets
 Sharing data easily with the outside world
 Where to go next
2
DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Evolution of Data Access
Combining the best of the past to meet the demands of the future
SDO
ProDataSet
Flexibility
TempTables
TempTables
XML
TempTables
ProDataSet
TempTables
TempTables
.NET
TempTables
Java
TempTables
Work File
.db
3
Host Centric
DEV-5: Using ProDataSets™ in OpenEdge® 10
.dbi
Client Server
Web
SOA
& Beyond
© 2007 Progress Software Corporation
Agenda
ProDataSets
 Evolution of data access
 Reasons to use ProDataSets
 Sharing data easily with the outside world
 Where to go next
4
DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Reasons to Use ProDataSets
Complex multi–level data structures as a single entity
 Strength of temporary tables
 Flexibility to group data for business needs
 Straight forward methods and events
 Data caching
 Batching
5
DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
The Strength of the Temporary Table
Based on the familiar temporary table
Outline view
6
DEV-5: Using ProDataSets™ in OpenEdge® 10
Color code text
© 2007 Progress Software Corporation
Temporary Tables Available for Use in UI
AppBuilder perspective uses temp-tables for building a browse
7
DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Reasons to Use ProDataSets
Complex multi–level data structures as a single entity
 Strength of temporary tables
 Flexibility to group data for business needs
 Straight forward methods and events
 Data caching
 Batching
8
DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Flexibility to Group Data for Business Needs

The DATA-RELATION
(OrderLine) defines the
relationship between
parent-child tables

The RELATION-FIELDS
(OrderNum, OrderNum)
define fields in parent and
child to use for selection
• Defaults for
– Populating
– Navigating
9
DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Data-Sources Easy to Use
 The Data-Source is a separate object from
the ProDataSet
• One for each temp-table buffer
• Can define database buffers or a query or
both
• XML methods allow easy loading of data from
external sources
10 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Relating the ProDataSet
Using relation fields to define foreign keys
Related Order lines
11 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Data-Sources Provide Data Flexibility
The Data-Source can be more complex
 Data-Source can flatten a triple join into a
single table
Related Order lines
12 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Ability to Modify the Query
 Because they are based on temp-tables it is
easy to use familiar QUERY-PREPARE to
select necessary records
Top level ONLY!
Child fills based on data
source and relation
13 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Reasons to Use ProDataSets
Complex multi–level data structures as a single entity
 Strength of temporary tables
 Flexibility to group data for business needs
 Straight forward methods and events
 Data caching
 Batching
14 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Filling a ProDataSet
Straight forward FILL method


Populate the ProDataSet from the Data-Sources
FILL on the DataSet
• Fills every table starting with top-level buffers

FILL on a buffer
• Fills that table and its descendents

FILL-MODE on each buffer
•
•
•
•
•
NO-FILL – skip this table
EMPTY – empty the table first
APPEND – add more records to the table
MERGE – add records & eliminate duplicates
REPLACE – replace existing records
15 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Populating with Data-Relations
Navigate.w
 When a DataSet is populated, OpenEdge
retrieves children of the current parent
ProDataSet
ttOrder
Order
Data-Source
6
84
144
1
1
1
02/09/06
02/09/06
02/09/06
Data-Relation
Application
ttOLine
Database
OrderLine
Data-Source
16 DEV-5: Using ProDataSets™ in OpenEdge® 10
6
6
6
1
2
3
00009
00009
00011
84
84
84
1
2
3
00009
00009
00011
© 2007 Progress Software Corporation
Event Callback Procedures
 You can define event procedures for:
• Before and After FILL of the ProDataSet
• Before and After FILL of any temp-table buffer
• Before and After FILL of any record
 Use ProDataSet events to prepare queries,



attach Data-Sources, etc.
Use Buffer events to manipulate the table
Use Record events to populate calculated
fields
You can use these events when
there is
no Data-Source at all
17 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Setting Callback Events
Advantage over .NET dataset is
the buffer storing current record
context (ttOrder)
18 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Navigating
dsOrderWinUp.w
1. Browse functionality
2. Query syntax
1
2
19 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Updating Through the ProDataSet
Defining a BEFORE-TABLE
 ProDataSet tables can have a companion
before-image temp-table to record updates
(add/change/delete)
• Used to pass changes to the server to be
made in the Data-Source and error messages
to the client
• Maps to .NET and Java support for update
versions
20 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Before-Image Table for a DataSet
dsOrderWinUp.w - Original record Values for order # 6
Delete Lines 2, 4, & 5
Modify Line 1 to have 60
Add 60 Fishing Lures (Item 44)
Add 30 Fishing Poles (Item 13)
21 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Before-Image Table for a DataSet
ProDataSet/dsCompareTables.w
 Select
ROW-DELETED
ROW-MODIFIED
ROW-CREATED
22 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Saving Changes to the Database
 SAVE-ROW-CHANGES method for saving a
row to the database
• Uses the before-table for optimistic locking
• Allows full control in the event of a conflict
 ERROR, ERROR-STRING, REJECTED,
DATA-SOURCE-MODIFIED attributes
23 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
ProDataSet Demo…
24 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Reasons to Use ProDataSets
Complex multi–level data structures as a single entity
 Strength of temporary tables
 Flexibility to group data for business needs
 Straight forward methods and events
 Data caching
 Batching
25 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Data Caching
Passing a ProDataSet as a Parameter
 DATASET – static reference like TABLE
 DATASET-HANDLE – dynamic reference to
the DataSet and its definition, like TABLEHANDLE – passes a simple DataSet handle
to a local procedure
 Note!
• By default the DATASET and DATASETHANDLE parameters copy the ProDataSet
contents (deep copy)
26 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Passing a ProDataSet BY-REFERENCE:
Local to a Single Session
27 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Remote DataSet Parameter BY-REFERENCE
BY-REFERENCE is ignored, always a deep copy
ProDataSet
TempTables
28 DEV-5: Using ProDataSets™ in OpenEdge® 10
TempTables
ProDataSet
TempTables
Deep Copy
TempTables
© 2007 Progress Software Corporation
Illustration of BY-REFERENCE Local Call
Please note example was coded without this option
ProDataSet
Unused ProDataSet
Order
DEFINE DATASET dsRef…
Order
Olines
DEFINE DATASET dsOrder
REFERENCE-ONLY.
Olines
dsOrder:FILL().
RUN FillWithWHERE IN
hOrderMain (INPUT icWhere,
OUTPUT DATASET dsRef BYREFERENCE).



Always the caller’s instance used
Called procedure instantiates a
ProDataSet that is never used
References are redirected for the
duration of that procedure call only
29 DEV-5: Using ProDataSets™ in OpenEdge® 10
PROCEDURE FillWithWhere:
DEFINE INPUT icWhere AS
CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER FOR
DATASET dsOrder.
dsOrder:FILL().
END PROCEDURE.
© 2007 Progress Software Corporation
Options for Parameters Local Call:
For Data Caching
ItemSelection.p
Unused ProDataSet
Pricelist
Define DATASET
dsPrices REFERENCEONLY…
RUN bindData IN hProc2 (OUTPUT
DATASET dsPrices BIND)
RUN fetchData IN hProc2.
DISPLAY <dsPrices fields>.



PriceListDataCache.p
ProDataSet
Pricelist
Define DATASET dsRef…
PROCEDURE bindData:
DEFINE OUTPUT PARAMETER
FOR DATASET dsRef BIND.
END PROCEDURE.
PROCEDURE fetchData:
dsRef:FILL().
ProDataSet – or temp-table – on one side of the call
is defined REFERENCE-ONLY
Use the BIND option on both sides of a single
procedure call
No need to pass the ProDataSet again!
30 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Summary of BY-REFERENCE and BIND
 BY-REFERENCE
• To use the caller’s ProDataSet instance in the
called procedure
 REFERENCE-ONLY
• For the unused instance
 BIND
• To identify called or caller procedure’s
instance to use
• Useful for data caching and separation of data
management from user interface
31 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Reasons to Use ProDataSets
Complex multi–level data structures as a single entity
 Strength of temporary tables
 Flexibility to group data for business needs
 Straight forward methods and events
 Data caching
 Batching
32 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Batching in a Distributed Stateless
Environment
AppServer
Client
Database
dsCustomer
eCustomer
dsCustomer
eCustomer
BATCH-SIZE
QUERY CustBrowse
LAST-BATCH
PROCEDURE offEnd:
OFF-END event
Procedure fetchWhere:
PROCEDURE fetchCustomers:
RUN fetchWhere ON hAppServer
NEXT-ROWID
RESTART-ROWID DATASET dsCustomer:FILL()
(OUTPUT DATASET dsCustomer) APPEND)
33 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
ProDataSet Events to Support Data Batching
 The goal is to make data retrieval with

batching transparent
OFF-END event for a ProDataSet query
• Occurs when a query goes off the end
• Occurs before Browse:OFF-END
• Occurs before Query:QUERY-OFF-END
 FIND-FAILED for a FIND on a buffer
• Use to respond to individual missing rows
34 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Sample Code for Batching
 Set up an event handler for OFF-END
QUERY CustBrowse:SET-CALLBACK(“OFF-END”, “OffEnd”).
 Define the event handler
PROCEDURE OffEnd:
DEFINE INPUT PARAMETER DATASET FOR dsCustomer.
IF NOT BUFFER eCustomer:LAST-BATCH THEN
DO:
RUN fetchCustomers.
RETURN NO-APPLY. /* Cancel OFF-END */
END.
END PROCEDURE.
35 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Requesting a Batch from the Server
 Make the request
RUN fetchWhere ON hServer
(INPUT “Customer”, INPUT iBatchSize,
INPUT-OUTPUT rRestartRowid,
INPUT cWhereString,
OUTPUT DATASET dsCustomer APPEND).
 Handle the request for data on the server
hCustBuffer:BATCH-SIZE = iBatchSize.
hDataSource:RESTART-ROWID(1) = rRestartRowid.
hCustQuery:QUERY-PREPARE(“FOR EACH Customer WHERE “
+ cWhereString).
DATASET dsCustomer:FILL().
IF hCustBuffer:LAST-BATCH = NO THEN
rRestartRowid = hDataSource:NEXT-ROWID(1).
36 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Agenda
ProDataSets
 Evolution of data access
 Reasons to use ProDataSets
 Sharing data easily with the outside world
 Where to go next
37 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Converting Between XML and ProDataSets
 Exporting the entire ProDataSet to XML
• WRITE-XML – creates XML stream from data
• WRITE-XMLSCHEMA – creates XML
Schema information based on the data
definition
• READ-XML – takes XML source and loads it
into a ProDataSet
– It can create the ProDataSet definition after a
CREATE DATASET statement
• READ-XMLSCHEMA – creates or verifies XML
Schema information
38 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Ability to Add External Data
Pulling in third party items from XML based documents
39 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Agenda
ProDataSets
 Evolution of data access
 Reasons to use ProDataSets
 Sharing data easily with the outside world
 Where to go next
40 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Relevant Exchange Sessions
Day Time
Session Title
Wed.
8:00 9:30 AM
DEV-14
Wed.
10:00 DEV-15
11:00 AM
Building a resilient Retail System
using WebClient, SonicMQ, and
ProDataSets
Wed.
10:00 DEV-16
11:00 AM
ABL Database Objects Updated
Wed.
3:30-5
Mastering ProDataSets and Native
XML Datatypes with Sonic ESB
INT-12
41 DEV-5: Using ProDataSets™ in OpenEdge® 10
Using ProDataSets and WebClient for
Robust B2B Applications
© 2007 Progress Software Corporation
For More Information, Go to…
 PSDN
• AutoEdge Application
• Application Architecture Made Simple
 Progress eLearning Community:
• Using ProDataSets
 Documentation:
• 10.1B ProDataSet Manual, by John Sadd
42 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
In Summary
 Leverages what you know
 Flexible and easy to use
 Allows applications to
combine data more effectively
to meet business needs
43 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Questions?
44 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
Thank you for
your time
45 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation
46 DEV-5: Using ProDataSets™ in OpenEdge® 10
© 2007 Progress Software Corporation