PROCEDURE fill_block (where_clause_in IN VARCHAR2) /* || Query data from table using a dynamic where clause and then || pass those values to an Oracle Forms block. */ IS /* || Declare cursor handle and parse the query, all in a single || statement using open_and_parse (see PARSE description). */ cursor_handle INTEGER := open_and_parse ('SELECT employee_id, last_name ' || ' FROM employee ' || ' WHERE ' || where_clause_in); /* Local variables to hold data from query */ empid INTEGER; empname VARCHAR2(60); /* return value from EXECUTE; ignore in case of query */ execute_feedback INTEGER; BEGIN /* Define the columns in the cursor for this query */ DBMS_SQL.DEFINE_COLUMN (cursor_handle, 1, empid); DBMS_SQL.DEFINE_COLUMN (cursor_handle, 2, empname, 30); /* Now I can execute the query */ execute_feedback := DBMS_SQL.EXECUTE (cursor_handle); LOOP /* Try to fetch next row. If done, then exit the loop. */ IF DBMS_SQL.FETCH_ROWS (cursor_handle) = 0 THEN EXIT; ELSE /* || Retrive data via calls to COLUMN_VALUE and place those || values in a new record in the block. */ DBMS_SQL.COLUMN_VALUE (cursor_handle, 1, empid); DBMS_SQL.COLUMN_VALUE (cursor_handle, 1, empname); CREATE_RECORD; :employee.employee_id := empid; :employee.employee_nm := empname; END IF; END LOOP; /* Clean up the cursor */ DBMS_SQL.CLOSE_CURSOR (cursor_handle); END;