" *****************************************************************************************************
*
*  loading.txt
*
*   This examples shows how to create and use loading SQLs
*
*
******************************************************************************************************"


| aModel aTextDisplay anOrb courses sqlStatement  courseType |
aTextDisplay := TextWindow  windowLabeled: 'LPC Brokers - creating and using Loading SQLs'
                           frame: (0 @ 0 corner: 500 @ 500).
aTextDisplay cr. 
 
aModel := LPCModel getName: #LpcSample.
courseType :=aModel typeNamed: #Course.
sqlStatement := 'Select * from course, section where course.Course = section.course and description like ''%Intro%'''.

"create the Loading SQLs"
courseType addLoadingSQL: #LpcSql 
                        sqlString: sqlStatement.

anOrb := LPCObjectRequestBroker new.
anOrb driverConnectWindow: aTextDisplay.

courses := anOrb lookUpUsingSql: (courseType loadingSQL: #LpcSql)
                                        withType: courseType.
courses do: [ :course | aTextDisplay nextPutAll: course asString ; cr ].
 
anOrb disconnect.
 
