" *****************************************************************************************************
*
*  loadin2.txt
*
*   This examples shows how to create and use loading SQLs
*   directly with a type.
*
*
******************************************************************************************************"


| aModel aTextDisplay anOrb courses sqlStatement  courseType |
aTextDisplay := TextWindow  windowLabeled: 'LPC Brokers -  using Loading SQLs - 2'
                           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. 

"set the model ORB"
aModel orb: anOrb.

courses := courseType lookUpUsingLoadingSQL: #LpcSql.
 courses do: [ :course | aTextDisplay nextPutAll: course asString ; cr ].
 
anOrb disconnect.
 
