Source Code for Search Engine 
DECLARE 
  i NUMBER (1); ‐‐loop counter 
  ResultCount NUMBER(3); ‐‐loop value 
BEGIN 
  ‐‐Validation Trigger, notify user if there is no search criteria entered 
  IF :KEYWORD.course_search IS NULL THEN 
    message('You do not insert any search criteria'); 
    RAISE form_trigger_failure; 
  ELSE null; 
  END IF; 
/* Count the number of records to be shown in the tabular datablock, based on the users' search  
criteria 
   Put the number of records into a variable ‐ Result Count, which is going to use for the loop limit 
     Use LIKE and wildcards & for searching records 
     Use LOWER(or UPPER) to turn all the search case insensitive */ 
SELECT COUNT(COURSE_CODE) INTO ResultCount FROM COURSE WHERE 
LOWER(COURSE_CODE) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%'  
OR LOWER(COURSE_NAME) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%'; 
  ‐‐Validation trigger, notify user if there is no result found 
  IF ResultCount=0 THEN 
    message('No courses are found base on your criteria'); 
    RAISE form_trigger_failure; 
  ELSE null; 
  END IF; 
   
‐‐Assign the value of i as 1 (notice that we use := for assigning a value, instead of =) 
  i:=1; 
  ‐‐Move the cursor to COURSE_SEARCH datablock 
  GO_BLOCK('COURSE_SEARCH'); 
  ‐‐Clear the data in the block (i.e., COURSE_SEARCH) 
  CLEAR_BLOCK(no_validate); 
  ‐‐Put the cursor to the first row of the datablock 
  First_Record; 
  ‐‐For loop, for i equals 1 to the loop limit 
  FOR i IN 1..ResultCount 
  LOOP 
    /*Select course code, name into the textbox locations 
Rownum (with an alias RN) is a system generated "sequence" of records, counts from i=1 
to i=loop limit 
    RN=i means one instance of the records selected */ 
    SELECT COURSE_CODE, COURSE_NAME             
    INTO :COURSE_SEARCH.COURSE_CODE, :COURSE_SEARCH.COURSE_NAME 
FROM (select course_code, course_name, rownum RN from course  
WHERE LOWER(COURSE_CODE) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%'  
OR LOWER(COURSE_NAME) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%') 
    WHERE RN=i; 
    ‐‐Put the cursor to the next record 
    Next_Record; 
  END LOOP; 
  ‐‐Put the cursor back to the first record 
First_Record;   
‐‐Put the cursor back to the Search textbox 
Go_Block('KEYWORD'); 
END; 

Source code for search engine(database)

  • 1.
    Source Code for Search Engine  DECLARE    i NUMBER (1); ‐‐loop counter    ResultCount NUMBER(3); ‐‐loop value  BEGIN   ‐‐Validation Trigger, notify user if there is no search criteria entered    IF :KEYWORD.course_search IS NULL THEN      message('You do not insert any search criteria');      RAISE form_trigger_failure;    ELSE null;    END IF;  /* Count the number of records to be shown in the tabular datablock, based on the users' search   criteria     Put the number of records into a variable ‐ Result Count, which is going to use for the loop limit       Use LIKE and wildcards & for searching records       Use LOWER(or UPPER) to turn all the search case insensitive */  SELECT COUNT(COURSE_CODE) INTO ResultCount FROM COURSE WHERE  LOWER(COURSE_CODE) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%'   OR LOWER(COURSE_NAME) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%';    ‐‐Validation trigger, notify user if there is no result found    IF ResultCount=0 THEN      message('No courses are found base on your criteria');      RAISE form_trigger_failure;    ELSE null;    END IF;     
  • 2.
    ‐‐Assign the value of i as 1 (notice that we use := for assigning a value, instead of =)    i:=1;    ‐‐Move the cursor to COURSE_SEARCH datablock   GO_BLOCK('COURSE_SEARCH');    ‐‐Clear the data in the block (i.e., COURSE_SEARCH)    CLEAR_BLOCK(no_validate);    ‐‐Put the cursor to the first row of the datablock    First_Record;    ‐‐For loop, for i equals 1 to the loop limit    FOR i IN 1..ResultCount    LOOP      /*Select course code, name into the textbox locations  Rownum (with an alias RN) is a system generated "sequence" of records, counts from i=1  to i=loop limit      RN=i means one instance of the records selected */      SELECT COURSE_CODE, COURSE_NAME                  INTO :COURSE_SEARCH.COURSE_CODE, :COURSE_SEARCH.COURSE_NAME  FROM (select course_code, course_name, rownum RN from course   WHERE LOWER(COURSE_CODE) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%'   OR LOWER(COURSE_NAME) LIKE '%'||LOWER(:KEYWORD.COURSE_SEARCH)||'%')      WHERE RN=i;      ‐‐Put the cursor to the next record      Next_Record;    END LOOP;    ‐‐Put the cursor back to the first record  First_Record;    ‐‐Put the cursor back to the Search textbox  Go_Block('KEYWORD');  END;