Posts

Showing posts with the label parent child

Parent Child Table (part 4)

 Welcome back! Continuing on with the Save Procedure.  In order for the children to be linked to their Parent, the Parent MUST be saved prior to the children.  So, lets focus in on the bottom end of the SQL INSERT: PassFail = DB::Update(DBID, Sql$) If PassFail *Class\State = DB::#Clean *Class\ID = DB::getLastID(DBID, "Galaxy") EndIf DB::Close(DBID) ;----------------------------------------------- SaveSolarSystemCollection(*Class) ;----------------------------------------------- As you can see once we close the database and retrieve the Parent's ID from the database, we then call the Save Children Procedure.  On the SQL UPDATE, we are free to call the Child Save Procedure immediately after the Close Procedure. PassFail = DB::Update(DBID, Sql$) If PassFail *Class\State = DB::#Clean EndIf DB::Close(DBID) ;--------------------...

Parent Child Table (Part 3)

 Moving on to the Find Methods.  Here again we have some changes. After we load up our Parent Record, we then need to load up its children.  I'll focus in on the in the code segment below: PassFail = DB::Query(DBID, Sql$) If PassFail While NextDatabaseRow(DBID) With *Class \ID = GetDatabaseLong(DBID, DatabaseColumnIndex(DBID,"ID")) \Name = GetDatabaseString(DBID, DatabaseColumnIndex(DBID,"Name")) \State = DB::#Clean EndWith Wend EndIf DB::Close(DBID) ClearList(*Class\SolarSystemCollection.SOLARSYSTEM::SolarSystem()) ;----------------------------------------------- LoadSolarSystemCollection(*Class) ;----------------------------------------------- ProcedureReturn PassFail Here you can see After the Parent Record is loaded, and the database Closed, we then Clear the List in preparation for loading it, then we call a new Procedure to Load the Child Collection. ...

Parent Child Table (Part 2)

Our First difference will be in the Structure definition. Structure Galaxy ID.i ; Table Primary Key Name.s ; Name of Galaxy List SolarSystemCollection.SOLARSYSTEM::SolarSystem() List DeleteSolarSystemCollection.SOLARSYSTEM::SolarSystem() State.i EndStructure As you can see, I've added in two Lists. The first: SolarSystemCollection which is a List of our Child Collection Records. And the second is called DeleteSolarSystemCollection which also is a List of our Child Collection Records. Now EACH of our Parent Records can contain the Children linked to it.  Now let us go through the Procedures and make the necessary changes to accommodate these Child Lists. The First Change we'll have will be to the Init and Dispose Methods. Procedure Dispose(*Class.Galaxy) ;Dispose all Child Collections ForEach SolarSystemCollection() SOLARSYSTEM::Dispose(@SolarSystemCollection()) Next FreeList(SolarSystem...