Title: DEV-5: Using ProDataSets
1DEV-5 Using ProDataSetsin OpenEdge 10
Cheryl LaBarge
Product Readiness
2Agenda
ProDataSets
- Evolution of data access
- Reasons to use ProDataSets
- Sharing data easily with the outside world
- Where to go next
3Evolution of Data Access
Combining the best of the past to meet the
demands of the future
SDO
ProDataSet
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
XML
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
ProDataSet
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Flexibility
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
.NET
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Java
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Work File
Â
Â
Â
Â
Â
Â
Â
.db
.dbi
Web SOA Beyond
Client Server
Host Centric
4Agenda
ProDataSets
- Evolution of data access
- Reasons to use ProDataSets
- Sharing data easily with the outside world
- Where to go next
5Reasons to Use ProDataSets
Complex multilevel 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
6The Strength of the Temporary Table
Based on the familiar temporary table
Color code text
Outline view
7Temporary Tables Available for Use in UI
AppBuilder perspective uses temp-tables for
building a browse
8Reasons to Use ProDataSets
Complex multilevel 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
9Flexibility 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
10Data-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
11Relating the ProDataSet
Using relation fields to define foreign keys
Related Order lines
12Data-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
13Ability 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
14Reasons to Use ProDataSets
Complex multilevel 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
15Filling 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
16Populating with Data-Relations
Navigate.w
- When a DataSet is populated, OpenEdge retrieves
children of the current parent
ProDataSet
Order Data-Source
Application Database
Data-Relation
ttOLine
6 1 000096 2 000096 3 00011
OrderLine Data-Source
84 1 0000984 2 0000984 3 00011
17Event 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
18Setting Callback Events
Advantage over .NET dataset is the buffer storing
current record context (ttOrder)
19Navigating
dsOrderWinUp.w
- Browse functionality
- Query syntax
20Updating 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
21Before-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)
22Before-Image Table for a DataSet
ProDataSet/dsCompareTables.w
ROW-DELETED ROW-MODIFIED ROW-CREATED
23Saving 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-MODIFIE
D attributes
24ProDataSet Demo
25Reasons to Use ProDataSets
Complex multilevel 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
26Data Caching
Passing a ProDataSet as a Parameter
- DATASET static reference like TABLE
- DATASET-HANDLE dynamic reference to the DataSet
and its definition, like TABLE-HANDLE passes a
simple DataSet handle to a local procedure - Note!
- By default the DATASET and DATASET-HANDLE
parameters copy the ProDataSet contents (deep
copy)
27Passing a ProDataSet BY-REFERENCELocal to a
Single Session
28Remote DataSet Parameter BY-REFERENCE
BY-REFERENCE is ignored, always a deep copy
AppServer
ProDataSet
ProDataSet
Deep Copy
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Temp-Tables
Â
Â
Â
Â
Â
Â
Â
Client
29Illustration of BY-REFERENCE Local Call
Please note example was coded without this option
ProDataSet
Unused ProDataSet
Order
Â
Order
Â
Olines
Â
Â
Â
DEFINE DATASET dsRef
DEFINE DATASET dsOrder REFERENCE-ONLY.
Olines
Â
Â
Â
dsOrderFILL().
PROCEDURE FillWithWhere DEFINE INPUT icWhere AS
CHARACTER NO-UNDO. DEFINE OUTPUT PARAMETER FOR
DATASET dsOrder. dsOrderFILL(). END PROCEDURE.
RUN FillWithWHERE IN hOrderMain (INPUT icWhere,
OUTPUT DATASET dsRef BY-REFERENCE).
- Always the callers instance used
- Called procedure instantiates a ProDataSet that
is never used - References are redirected for the duration of
that procedure call only
30Options for Parameters Local CallFor Data
Caching
PriceListDataCache.p
ProDataSet
ItemSelection.p
Unused ProDataSet
Pricelist
Pricelist
Define DATASET dsPrices REFERENCE-ONLY
Define DATASET dsRef
PROCEDURE bindData DEFINE OUTPUT PARAMETER FOR
DATASET dsRef BIND. END PROCEDURE.
RUN bindData IN hProc2 (OUTPUT DATASET dsPrices
BIND)
RUN fetchData IN hProc2. DISPLAY ltdsPrices
fieldsgt.
PROCEDURE fetchData dsRefFILL().
- 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!
31Summary of BY-REFERENCE and BIND
- BY-REFERENCE
- To use the callers ProDataSet instance in the
called procedure - REFERENCE-ONLY
- For the unused instance
- BIND
- To identify called or caller procedures instance
to use - Useful for data caching and separation of data
management from user interface
32Reasons to Use ProDataSets
Complex multilevel 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
33Batching in a Distributed Stateless Environment
AppServer
Client
Database
dsCustomer
eCustomer
dsCustomer
eCustomer
BATCH-SIZE
QUERY CustBrowse
LAST-BATCH
OFF-END event
PROCEDURE offEnd
NEXT-ROWID
Procedure fetchWhere DATASET dsCustomerFILL()
PROCEDURE fetchCustomers RUN fetchWhere ON
hAppServer (OUTPUT DATASET dsCustomer)
RESTART-ROWID
APPEND)
34ProDataSet 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 BrowseOFF-END
- Occurs before QueryQUERY-OFF-END
- FIND-FAILED for a FIND on a buffer
- Use to respond to individual missing rows
35Sample Code for Batching
- Set up an event handler for OFF-END
QUERY CustBrowseSET-CALLBACK(OFF-END,
OffEnd).
PROCEDURE OffEnd DEFINE INPUT PARAMETER
DATASET FOR dsCustomer. IF NOT BUFFER
eCustomerLAST-BATCH THEN DO RUN
fetchCustomers. RETURN NO-APPLY. / Cancel
OFF-END / END. END PROCEDURE.
36Requesting a Batch from the Server
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
hCustBufferBATCH-SIZE iBatchSize.
hDataSourceRESTART-ROWID(1) rRestartRowid.
hCustQueryQUERY-PREPARE(FOR EACH Customer WHERE
cWhereString). DATASET dsCustomerFILL(). IF
hCustBufferLAST-BATCH NO THEN rRestartRowid
hDataSourceNEXT-ROWID(1).
37Agenda
ProDataSets
- Evolution of data access
- Reasons to use ProDataSets
- Sharing data easily with the outside world
- Where to go next
38Converting 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
39Ability to Add External Data
Pulling in third party items from XML based
documents
40Agenda
ProDataSets
- Evolution of data access
- Reasons to use ProDataSets
- Sharing data easily with the outside world
- Where to go next
41Relevant Exchange Sessions
Day Time Session Title
Wed. 800 -930 AM DEV-14 Using ProDataSets and WebClient for Robust B2B Applications
Wed. 1000 -1100 AM DEV-15 Building a resilient Retail System using WebClient, SonicMQ, and ProDataSets
Wed. 1000 -1100 AM DEV-16 ABL Database Objects Updated
Wed. 330-5 INT-12 Mastering ProDataSets and Native XML Datatypes with Sonic ESB
42For More Information, Go to
- PSDN
- AutoEdge Application
- Application Architecture Made Simple
- Progress eLearning Community
- Using ProDataSets
- Documentation
- 10.1B ProDataSet Manual, by John Sadd
43In Summary
- Leverages what you know
- Flexible and easy to use
- Allows applications to combine data more
effectively to meet business needs
44Questions?
45Thank you foryour time
46(No Transcript)