< Previous | Next >

Completed CustomerTableOperations.egl and duplicateTable.egl files after lesson 6

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

package libraries;

import eglderbyr7.ConditionHandlingLib;
import eglderbyr7.StatusRec;

library CustomerTableOperations type BasicLibrary {}

  function execCreateTable(status StatusRec inOut)
    try
      execute 
        #sql{
          CREATE TABLE EGL.CUSTOMERTEMP (
              CUSTOMER_ID INTEGER NOT NULL,
              FIRST_NAME VARCHAR(30),
              LAST_NAME VARCHAR(30),
              PASSWORD CHAR(8),
              PHONE VARCHAR(14),
              EMAIL_ADDRESS VARCHAR(50),
              STREET VARCHAR(30),
              APARTMENT VARCHAR(10),
              CITY VARCHAR(30),
              STATE CHAR(2),
              POSTALCODE VARCHAR(10),
              DIRECTIONS VARCHAR(255)
            )
          };
    onException (exception SQLException)
      ConditionHandlingLib.HandleException(status, exception);
    end
    
  end
  
  function execInsertIntoTable(status StatusRec inOut)
    try  
      execute #sql{
      INSERT INTO EGL.CUSTOMERTEMP 
        SELECT * FROM EGL.CUSTOMER
         } ;
    onException (exception SQLException)
      ConditionHandlingLib.HandleException(status, exception);
    end
  end
  
  function execDropTable(status StatusRec inOut)
    try  
      execute #sql{
        DROP TABLE EGL.CUSTOMERTEMP
        } ;
    onException (exception SQLException)
      ConditionHandlingLib.HandleException(status, exception);
    end
  end
  
end


[programs/duplicateTable.egl]

package programs;

import eglderbyr7.StatusRec;
import libraries.CustomerTableOperations;

program duplicateTable type BasicProgram {}
  
  status StatusRec;
  
  function main()
    CustomerTableOperations.execCreateTable(status);
    CustomerTableOperations.execInsertIntoTable(status);
    //CustomerTableOperations.execDropTable(status);
  end
  
end

Return to Lesson 6: Executing arbitrary SQL code.

< Previous | Next >

Feedback