< Previous | Next >

Completed SearchLibrary.egl file after lesson 4

This code is the version of the SearchLibrary.egl file completed after lesson 4. If you see any errors marked by red X symbols in the file, make sure your code matches this code:
package libraries;
import eglderbydb.data.Customer;

library SearchLibrary type BasicLibrary

	function NameAndStateSearch_And(lname STRING in, 
		state CHAR(2) in, customer Customer[])
		get customer with
			#sql{
				select
					CUSTOMERID, FIRSTNAME, LASTNAME, PASSWORD, PHONE, 
					EMAILADDRESS, STREET, APARTMENT, CITY, "STATE", 
					POSTALCODE, DIRECTIONS
				from EGL.CUSTOMER
				where LASTNAME like :lname 
					and "STATE" = :state
				order by
					CUSTOMERID asc
			};
	end

	function NameAndStateSearch_Or(lname STRING in, 
		state CHAR(2) in, customer Customer[])
		get customer with
			#sql{
				select
					CUSTOMERID, FIRSTNAME, LASTNAME, PASSWORD, PHONE, 
					EMAILADDRESS, STREET, APARTMENT, CITY, "STATE", 
					POSTALCODE, DIRECTIONS
				from EGL.CUSTOMER
				where LASTNAME like :lname 
					or "STATE" = :state
				order by
					CUSTOMERID asc
			};
	end

	function getAllCustomerStates(listOfStates STRING[])
		customers Customer[0];
		counter INT;

		get customers with
			#sql{
				select "STATE"
				from EGL.CUSTOMER
				order by "STATE" asc
 			};

		listOfStates.removeAll();
		for (counter from 1 to customers.getSize() by 1)
			listOfStates.appendElement(customers[counter].State);
		end

	end
end

Return to Lesson 4: Populate a combo box dynamically.

< Previous | Next >

Feedback