Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Oracle Forms : Query Triggers

1,964 views

Published on

Oracle Forms : Query Triggers

Published in: Software
  • Be the first to comment

  • Be the first to like this

Oracle Forms : Query Triggers

  1. 1. Query Triggers
  2. 2. Objectives • How Query Processing occurs in Forms? • Writing Pre-Query Trigger • Writing Post-Query Trigger • Scope of the triggers and Built-ins
  3. 3. Query Processing Perform queryPerform query Fetch a row into a new recordFetch a row into a new record Mark record as validMark record as valid Fire Post-Query triggerFire Post-Query trigger Validate any record changesValidate any record changes Abort query on failure Flush record on failure Construct SELECT...Construct SELECT... Fire Pre-Query triggerFire Pre-Query trigger
  4. 4. Where & Order By Clauses • Three sources for Where Clause – Query/Where Dialog Box – Example Record – Where Clause Block Property Where Clauses are combined by the AND Operator. • Two sources for Order By Clause – Order by Clause Block Property – Query/Where Dialog Box Second source for Order by clause Overrides the first one.
  5. 5. SELECT statement Issued SELECT base_column, ..., ROWID INTO :base_item, ..., :ROWID FROM base_table WHERE default_where_clause AND (example_record_conditions) AND (query_where_conditions) ORDER BY default_order_by_clause | query_where_order_by
  6. 6. Pre-Query Trigger • Defined at the Block-level • Fires once before the query is issued. IF :emp.enmpno||:emp.ename|| :emp.hiredate IS NULL THEN MESSAGE(‘You must query on emp id or name or joindate’); RAISE form_trigger_failure; --Built-in Exception END IF;
  7. 7. Post-Query Trigger • Written at Block level • Use to populate nondatabase items and calculate statistics • Fires once for each fetched record. • SELECT dname INTO :control.dept_name FROM dept WHERE deptno=:emp.deptno;
  8. 8. Query Array Processing • Reduces network traffic • Enables Query Array processing: – Enable Array Processing option – Set Query Array Size property • Query Array Size property • Query All Records property
  9. 9. Enter-Query Mode • Some triggers may fire in Enter-Query mode. • Set to fire in Enter-Query Mode property. • Test mode during execution with :SYSTEM.MODE – NORMAL – ENTER-QUERY – QUERY IF :SYSTEM.MODE = ’NORMAL’ THEN ENTER_QUERY; ELSE EXECUTE_QUERY; END IF;
  10. 10. Query Info at Runtime • SYSTEM.MODE • SYSTEM.LAST_QUERY –Contains bind variables (EMPNO = :1) before SELECT_RECORDS –Contains actual values (EMPNO = 7566) after SELECT_RECORDS
  11. 11. Query Info at Runtime • GET_BLOCK_PROPERTY SET_BLOCK_PROPERTY – Get and set: DEFAULT_WHERE ORDER_BY QUERY_ALLOWED QUERY_HITS – Get only: QUERY_OPTIONS RECORDS_TO_FETCH
  12. 12. Query Info at Runtime • GET_ITEM_PROPERTY SET_ITEM_PROPERTY – Get and set: CASE_INSENSITIVE_QUERY QUERYABLE QUERY_ONLY – Get only: QUERY_LENGTH
  13. 13. Summary • Where clauses are combined with AND Operator • Second Order by Overrides the first one. • A Pre-Query trigger fires before a query executes. Use it to check or modify query conditions. • A Post-Query trigger fires as each record is fetched. Use it to perform calculations and populate additional items.

×