< Previous | Next >

Completed SearchLibrary.egl file after lesson 5

This code is the version of the SearchLibrary.egl file completed after lesson 5. 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

	function getOneState(state Statetable)
		get state;
	end
end

record customizedResult type basicRecord
	fullName STRING {displayName = "Full Name"};
	email STRING {displayName = "Email Address"};
	stateName STRING {displayName = "State"};
end

Return to Lesson 5: Customize the search results.

< Previous | Next >

Feedback