Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Temporary private data session
Message
From
08/03/2000 15:59:29
Bob Tracy
Independent Consultant
Driftwood, Texas, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00343415
Message ID:
00343436
Views:
19
David,
In addition to agreeing to what Larry posted, here's some code I'm using to do a similar trick (but not with XML)(sorry the indentation doesn't come through):

* datafactory.RetrieveHierarchy
* Returns a shaped data object much like ADO Shaped RecordSets.
* The child records are collected in the "oDetail" property of oHeader.
* oHeader.DetailCount is the count of child records.
LPARAMETERS tcParentFields, ;
tcChildFields, ;
tcParentTable, ;
tcChildTable, ;
tcParentFilter, ;
tcRelation
LOCAL luParentKey,luChildKey,lcSQL,oConn,n,lnCount,lnID,lcFilter
* Parse the tcRelation values
luParentKey = SUBSTR(tcRelation,1,AT(',',tcRelation)-1)
luChildKey = SUBSTR(tcRelation,AT(',',tcRelation)+1)
* Get a database connection
oConn = THIS.oConnection
* Parse the SQL string
lcSQL = THIS.ParseSQL(tcParentFields,tcParentTable,tcParentFilter)
* Execute the SQL statement
&lcSQL
* Check for a valid return. < or > 1 is an error.
SELE curTemp
lnCount = RECCOUNT()
IF lnCount = 1
* Get an instance of the data object for the parent record
oHeader = NEWOBJECT(dfNewDataObject,dfAbstractLib)
* Add the necessary properties to the data object
WITH oHeader
.AddProperty('oRecord[1,1]')
.AddProperty('oDetail[1,1]')
.AddProperty('DetailCount')
ENDWITH
* Put the header record in the data object
SCATTER NAME oHeader.oRecord[1] MEMO
* Get the header record primary key
lnID = oHeader.oRecord[1].&luParentKey
* Build a SQL statement for the child data
lcFilter = "WHERE "+luChildKey+" = "+ALLT(STR(lnID,6,0))
lcFilter = lcFilter+" AND !DELETED()"
* Parse the child SQL statement
lcSQL = THIS.ParseSQL(tcChildFields,tcChildTable,lcFilter)
* Execute the SQL statement
&lcSQL
SELE curTemp
lnCount = RECCOUNT()
IF lnCount > 0
DIMENSION oHeader.oDetail[lnCount]
* Add the detail records to the data object
FOR n = 1 TO lnCount
SCATTER NAME oHeader.oDetail[n] MEMO
SKIP
NEXT n
oHeader.DetailCount = lnCount
ENDIF
USE
RETURN oHeader
ELSE
RETURN 'Record Not Found'
ENDIF
Bob Tracy

Never engage in a battle of wits if you're only half armed.
Previous
Reply
Map
View

Click here to load this message in the networking platform