< Previous | Next >

Completed printCustomerOrders.egl and records.egl files after lesson 5

This code is the completed version of the printCustomerOrders.egl and records.egl files after lesson 5. If you see any errors marked by red X symbols in either file, make sure your code matches this code:
[data/records.egl]

package data;

record OrderCustomerJoin type SQLRecord
  {tableNames = [["EGL.CUSTOMER", "C"], ["EGL.ORDERS", "O"]], 
  keyItems=[CUSTOMER_ID, ORDER_ID],
  defaultSelectCondition = #sqlCondition{ O.CUSTOMER_ID = C.CUSTOMER_ID }}

  CUSTOMER_ID int
    {column="C.CUSTOMER_ID", isReadOnly=yes};
  FIRST_NAME string
    {column="C.FIRST_NAME", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=30};
  LAST_NAME string
    {column="C.LAST_NAME", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=30};
  PASSWORD string
    {column="C.PASSWORD", isReadOnly=yes, 
      isSqlNullable=yes, maxLen=8};
  PHONE string
    {column="C.PHONE", isReadOnly=yes, isSqlNullable=yes, 
      sqlVariableLen=yes, maxLen=14};
  EMAIL_ADDRESS string
    {column="C.EMAIL_ADDRESS", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=50};
  STREET string
    {column="C.STREET", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=30};
  APARTMENT string
    {column="C.APARTMENT", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=10};
  CITY string
    {column="C.CITY", isReadOnly=yes, isSqlNullable=yes, 
      sqlVariableLen=yes, maxLen=30};
  STATE string
    {column="C.STATE", isReadOnly=yes, 
      isSqlNullable=yes, maxLen=2};
  POSTALCODE string
    {column="C.POSTALCODE", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=10};
  DIRECTIONS string
    {column="C.DIRECTIONS", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=255};
  ORDER_ID int
    {column="O.ORDER_ID", isReadOnly=yes};
  orders_CUSTOMER_ID int
    {column="O.CUSTOMER_ID", isReadOnly=yes, 
      isSqlNullable=yes};
  ORDER_AMOUNT decimal(8,2)
    {column="O.ORDER_AMOUNT", isReadOnly=yes, 
      isSqlNullable=yes};
  ORDER_DETAILS string
    {column="O.ORDER_DETAILS", isReadOnly=yes, 
      isSqlNullable=yes, sqlVariableLen=yes, maxLen=111};
  ORDER_DATE date
    {column="O.ORDER_DATE", isReadOnly=yes, 
      isSqlNullable=yes};
  ORDER_STATUS string
    {column="O.ORDER_STATUS", isReadOnly=yes, 
      isSqlNullable=yes, maxLen=12};
end

[programs/printCustomerOrders.egl]

package programs;

import data.OrderCustomerJoin;

program printCustomerOrders type BasicProgram {}
  
  function main()
    
    allCustomerOrders OrderCustomerJoin[0];
    
    tempRec OrderCustomerJoin;
    open resultSet for tempRec;
    forEach (tempRec)
      SysLib.writeStdout(tempRec.CUSTOMER_ID :: " " 
        :: tempRec.LAST_NAME :: " " :: tempRec.ORDER_ID);
    end
    
  end
  
end

Return to Lesson 5: Retrieving more complex data with table joins.

< Previous | Next >

Feedback