dev-16: abl database objects updated david olson director, enterprise solutions mary szekely just...
TRANSCRIPT
DEV-16: ABL Database Objects Updated
David OlsonDirector, Enterprise Solutions
Mary SzekelyJust Mary
© 2007 Progress Software Corporation2 DEV-16: ABL Database Objects Updated
Agenda
ProDataSets in perspective What’s new for DB objects in 10.1C Getting more out of your DB objects
© 2007 Progress Software Corporation3 DEV-16: ABL Database Objects Updated
The data relation Order to Order-Lines can be represented as composite rows or “tuples”:• Order 3 01/02/07 Order-line 1 95• Order 3 01/02/07 Order-line 2 44
The same data relation can be represented in nested fashion as:• Order 3 01/02/07
– Order-line 1 95– Order-line 2 44
ProDataSets in Perspective
ProDataSets are about data relations between tables.
© 2007 Progress Software Corporation4 DEV-16: ABL Database Objects Updated
ProDataSets in Perspective
The “tuple” form of data: The Result Set
Order-num Ordered Cust-num Cust-name Line-num Qty Item-num Item-name Price
3 01/02/07 66 First Down Football 1 95 45 Golf Shoes 81.00
3 01/02/07 66 First Down Football 2 44 54 Shin Pads 4.86
3 01/02/07 66 First Down Football 3 71 4 Cycle Helmet 75.00
3 01/02/07 66 First Down Football 4 90 30 Windbreaker 42.75
3 01/02/07 66 First Down Football 5 98 2 Tennis Racquet 64.50
3 01/02/07 66 First Down Football 6 67 32 Tennis Shorts 19.99
4 02/15/07 83 Fallen Arch Running 1 78 2 Tennis Racquet 64.50
4 02/15/07 83 Fallen Arch Running 2 38 30 Windbreaker 42.75
4 02/15/07 83 Fallen Arch Running 3 4 43 Frisbee 13.97
4 02/15/07 83 Fallen Arch Running 4 72 40 Ice Skates 61.00
4 02/15/07 83 Fallen Arch Running 5 21 8 Runner’s Vest 9.85
4 02/15/07 83 Fallen Arch Running 6 97 53 Swimming Trunks 8.77
4 02/15/07 83 Fallen Arch Running 7 78 19 Ski Wax - Red 2.75
© 2007 Progress Software Corporation5 DEV-16: ABL Database Objects Updated
Wide SQL tuple has extra copies of higher levels• Each row is independent of all other data
• Updating can be difficult
• Ideal for streaming large amounts of data where processing cannot wait for a completed set
The Trouble with Result Sets
Distributing data: SQL “tuples” versus datasets
© 2007 Progress Software Corporation6 DEV-16: ABL Database Objects Updated
ProDataSets in Perspective
Typical XML format of the same data. Foreign keys deduced by context, still with some redundancy.
<?xml version="1.0" ?> - <OrderDataSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">- <ttOrder> <CustNum>66</CustNum> <OrderNum>3</OrderNum> <OrderDate>1997-09-23</OrderDate> </ttOrder>- <ttOrder> <CustNum>83</CustNum> <OrderNum>4</OrderNum> <OrderDate>1998-01-17</OrderDate> </ttOrder>- <ttCust> <CustNum>66</CustNum> <NAME>First Down Football</NAME> </ttCust>- <ttCust> <CustNum>83</CustNum> <NAME>Fallen Arch Running</NAME> </ttCust>- <ttOrderLine> <OrderNum>3</OrderNum> <LineNum>1</LineNum> <ItemNum>45</ItemNum> <Qty>95</Qty> </ttOrderLine>
© 2007 Progress Software Corporation7 DEV-16: ABL Database Objects Updated
CUSTOMER
Cust-num Cust-name
66 First Down Football
83 Fallen Arch Running etc.
ProDataSets in Perspective
ORDER
Cust-num Order-num Ordered
66 3 01/02/07
83 4 02/15/07
Normalized data: The Business View of Data
ORDER-LINE
Order-num Item-num Line-num Qty
3 45 1 95
3 54 2 44
3 4 3 71
3 30 4 90
3 2 5 98
3 32 6 67
4 2 1 78
4 30 2 38
4 43 3 4
4 40 4 72
4 8 5 21
4 53 6 97
4 19 7 78
ITEM
Item-num Item-name Price
4 Tennis Racket 64.50
2 Cycle Helmet 75.00
8 Runner’s Vest 9.85
19 Duffel Bag 50.00
30 Windbreaker 42.75
32 Tennis Shorts 19.99
40 Ice Skates 61.00
43 Frisbee 13.97
45 Golf Shoes 81.00
53 Swimming Trunks 8.77
54 Shin Pads 4.86
© 2007 Progress Software Corporation8 DEV-16: ABL Database Objects Updated
Dataset format has no extra copies• One row in a table is dependent on rows in
other tables, so no processing can occur until the entire set has been read
• Ideal for caching moderate amounts of data
• Ideal for loosely-coupled operations
• Updating is safe and easy– Browsing easy
DataSets are Fun
Distributing data: SQL “tuples” versus datasets
© 2007 Progress Software Corporation9 DEV-16: ABL Database Objects Updated
Deliver related data as tables of logical records, not as tuples in a matrix
Guarantee updating can be safe and effective, including before images for optimistic locking
Minimize data transmission
Can be transformed to and from XML easily
Do not assume all data comes from one data source
May be defined dynamically
DataSet Principles
ProDataSets, ABL SDOs, Java™ SDOs, .NET™ Datasets
© 2007 Progress Software Corporation10 DEV-16: ABL Database Objects Updated
Agenda
ProDataSets in perspective What’s new for DB objects in 10.1C Getting more out of your DB objects
© 2007 Progress Software Corporation11 DEV-16: ABL Database Objects Updated
D I S C L A I M E R
Under Development
This talk includes information about potential future products and/or product enhancements.
What we are going to say reflects our current thinking, but the information contained herein is preliminary and subject to change. Any future products we ultimately deliver may be materially different from what is described here.
D I S C L A I M E R
© 2007 Progress Software Corporation12 DEV-16: ABL Database Objects Updated
Buffer handle method MARK-ROW-STATEAllows you to create a before-table record for any after-table record with a row-state and before-table buffer of your choice
Buffer handle method MARK-NEWAllows you to create before-table records and mark them as ROW-CREATED for an entire temp-table
Adventures in Buffer Methods
Ability to create dataset Before-Table records on the Server side for uniform update with SAVE-ROW-CHANGES
Useful for WebSpeed and data coming from XML
© 2007 Progress Software Corporation13 DEV-16: ABL Database Objects Updated
Recursive Relationships
PARTS
part-num part-location mcost
66 London 12.95
83 Hong Kong 22.50
46 Billerica 15.25
21 Santa Cruz 143.88
46 Nashua 41.95
25 Springfield 16.75
19 Newark 4.95
PRODUCT-STRUCTURE
comp-num assy-num qty
66 3 2
83 4 5
46 8 15
21 2 3
46 5 19
25 12 9
19 7 2
part-num to assy-num comp-num to part-num
© 2007 Progress Software Corporation14 DEV-16: ABL Database Objects Updated
DEFINE TEMP-TABLE ttpart FIELD part-num AS CHAR FIELD mcost AS DECIMAL INDEX part-num AS UNIQUE part-num.
DEFINE TEMP-TABLE ttps FIELD comp-num AS CHAR FIELD assy-num AS CHAR FIELD qty AS INT INDEX ixcomp AS UNIQUE comp-num assy-num. INDEX ixassy AS UNIQUE assy-num comp-num.
DEFINE DATASET mfg FOR ttpart, ttps DATA-RELATION FOR ttpart, ttps RELATION-FIELDS(part-num, assy-num) DATA-RELATION FOR ttps, ttpart RELATION-FIELDS(comp-num, part-num) RECURSIVE.
Dataset Recursion
FILL a Dataset through a Recursive Relation
RECURSIVE property for DATA-RELATIONS – manufacturing example
© 2007 Progress Software Corporation15 DEV-16: ABL Database Objects Updated
Recursive Relationships
Single Table Recursion
The Trouble with Management
Niel
David Ken Peter
Mary Martha
Robert Evan
Alex Robin Rich
© 2007 Progress Software Corporation16 DEV-16: ABL Database Objects Updated
Recursive Relationships
EMPLOYEE
emp-name manager
Niel
David Niel
Ken Niel
Peter Niel
Martha Peter
Evan Martha
Robin Evan
Rich Evan
Mary Ken
Alex Robert
Robert Martha
The Trouble with Management• Managers are employees• Navigation through self-recursion
can be difficult
Relationship tables: EMPLOYEE and EMPLOYEERelationship fields: emp-name and manager
Single Table Recursion
Niel
David Ken Peter
Mary Martha
Robert Evan
Alex Robin Rich
© 2007 Progress Software Corporation17 DEV-16: ABL Database Objects Updated
RECURSIVE property for DATA-RELATIONS
Single Table model
Dataset Recursion
FILL a Dataset through a Recursive Relation
DEFINE TEMP-TABLE ttemp FIELD emp-name AS CHAR FIELD manager AS CHAR FIELD age as int INDEX emp-name AS UNIQUE emp-name.
DEFINE DATASET myorg FOR ttemp DATA-RELATION r1 FOR ttemp,ttemp RELATION-FIELDS(emp-name, manager)RECURSIVE.
© 2007 Progress Software Corporation18 DEV-16: ABL Database Objects Updated
Works for both dynamic and static QUERY OPEN
Working with Groups in Queries
BREAK BY, LAST-OF FIRST-OF for a QUERY
DEFINE QUERY q FOR Customer,Order, Order-line, Item SCROLLING.
OPEN QUERY q FOR EACH Customer WHERE Customer.Cust-num < 10, EACH Order OF Customer, EACH Order-line OF Order, EACH Item OF Order-lineBREAK BY Customer.Sales-rep BY Order.Order-num.
REPEAT: GET NEXT q. IF QUERY q:LAST-OF(2) THEN …. Done with this order IF QUERY q:LAST-OF(1) THEN … Done with this sales-rep etc etc.END.
© 2007 Progress Software Corporation19 DEV-16: ABL Database Objects Updated
REPEAT: GET NEXT q. IF QUERY-OFF-END(“q”) THEN LEAVE. tot-by-order = tot-by-order + qty * price. tot-by-rep = tot-by-rep + qty * price. IF QUERY q:LAST-OF(2) THEN /*Done with this order*/ DO: DISPLAY cust.sales-rep order.order-num tot-by-order. tot-by-order = 0. IF QUERY q:LAST-OF(1) THEN /*Done with this sales-rep*/ DO: DISPLAY tot-by-rep. tot-by-rep = 0. END. END.
END.
Working with Groups in Queries
Accumulating Totals
© 2007 Progress Software Corporation20 DEV-16: ABL Database Objects Updated
TEMP-TABLE and DATASET WRITE-XML, WRITE-XMLSCHEMA
TEMP-TABLE and DATASET READ-XML, READ-XMLSCHEMA• If receiving table or dataset is dynamic, we
can infer the schema!
Around since 10.1A but not talked about enough!
Handy features in DB objects
ProDataSet and Temp-table READ and WRITE XML & Schema
© 2007 Progress Software Corporation21 DEV-16: ABL Database Objects Updated
ProDataSets for consuming Web Services ProDataSets can be a parameter for the web service incoming call
Already available for Temp-Tables
Dataset parameters used to be done by serializing to XML
DB Object Enhancements
Other new features…
© 2007 Progress Software Corporation22 DEV-16: ABL Database Objects Updated
NOT-ACTIVE keyword for DATA-RELATION
DB Object Enhancements
Other new features…
def temp-table ttcust like customer.def temp-table ttord like order.
def dataset dset for ttcust,ttorddata-relation r1 for ttcust,ttord
relation-fields(cust-num,cust-num)data-relation r2 for ttord,ttcust
relation-fields(cust-num,cust-num) not-active.
dataset dset:get-relation("r1"):active = false.dataset dset:get-relation("r2"):active = true.
Note that ttcust, ttorder is suitable for FILL
ttord, ttcust, is suitable for NAVIGATION or sending to .NET
© 2007 Progress Software Corporation23 DEV-16: ABL Database Objects Updated
TOP-NAV-QUERY for datasets
READ/WRITE attribute for dataset members that are not children of any relation:
DB Object Enhancements
Other new features…
dataset d:top-nav-query:set-callback-procedure("off-end“ ,"fetchcusts").
browse b:query = dataset d:top-nav-query.
© 2007 Progress Software Corporation24 DEV-16: ABL Database Objects Updated
DEFAULT-VALUE for BUFFER-FIELDS
Similar to INITIAL and DEFAULT–STRING, but is in the NATIVE format, not CHARACTER.
For assigning values to a newly created record, but not for use as MetaData since TODAY and NOW are captured as the current internal native datatype date and time
DB Object Enhancements
Other new features…
© 2007 Progress Software Corporation25 DEV-16: ABL Database Objects Updated
Agenda
ProDataSets in perspective What’s new for DB objects in 10.1C Getting more out of your DB objects
© 2007 Progress Software Corporation26 DEV-16: ABL Database Objects Updated
FILL-WHERE-STRING is BOTH read/write and easier to use than creating your own query
Or
The query is automatically handled by the FILL and you do not have to worry about creating/deleting it yourself
Handy features in db objects
Filtering a ProDataset FILL query with FILL-WHERE-STRING
DATA-SOURCE dord-line:FILL-WHERE-STRING = DATA-SOURCE dord-line:FILL-WHERE-STRING + “ AND Line-Num < 3”.
DATA-SOURCE dsDept:FILL-WHERE-STRING = “where deptcode = ‘400’”.
© 2007 Progress Software Corporation27 DEV-16: ABL Database Objects Updated
If loose-copy-mode is TRUE:• The target and source member tables do not
have to have columns matching by position.
• They are matched by name, or by any previous ATTACH-DATA-SOURCE mapping between the target and source.
Handy features in db objects
Loose-copy-mode dataset and temp-table copy
target-dataset-handle:COPY-DATASET( src-dataset-handle [, append-mode [, replace-mode [, loose-copy-mode [, pairs-list [, current-only ]] ] ] ] )
© 2007 Progress Software Corporation28 DEV-16: ABL Database Objects Updated
TEMP-TABLE and DATASET WRITE-XML, WRITE-XMLSCHEMA
TEMP-TABLE and DATASET READ-XML, READ-XMLSCHEMA• If receiving table or dataset is dynamic, we
can infer the schema!
Around since 10.1A but not talked about enough!
Handy features in DB objects
ProDataSet and Temp-table READ and WRITE XML & Schema
© 2007 Progress Software Corporation29 DEV-16: ABL Database Objects Updated
In Summary
ProDataSets model REALREAL business data• Complex relationships and
recursion are easily managed New features make ProDataSets
more flexible• FILL-WHERE and loosemode are
examples
ProDataSets keep getting better• We can do things other datasets
cannot
© 2007 Progress Software Corporation30 DEV-16: ABL Database Objects Updated
For More Information, go to…
PSDN Library - http://www.psdn.com/library/index.jspa• 10.1B ProDataSets by John Sadd• 10.1B ABL Handbook by John Sadd
Education Courses:• Using ProDataSets
Documentation:• 10.1B ABL Reference
© 2007 Progress Software Corporation31 DEV-16: ABL Database Objects Updated
Relevant Exchange Sessions
DEV-5: Using ProDataSets in OpenEdge® 10• Monday, June 12, 2:00pm
DEV-14: Using ProDataSets and WebClient for Robust B2B Applications• Tuesday, June 13, 8:00am
DEV-13: Development Tools and ABL Roadmap Info Exchange• Tuesday, June 13, 8:00am
© 2007 Progress Software Corporation32 DEV-16: ABL Database Objects Updated
Questions?
© 2007 Progress Software Corporation33 DEV-16: ABL Database Objects Updated
Thank you foryour time
© 2007 Progress Software Corporation34 DEV-16: ABL Database Objects Updated