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: Data Blocks on Different Sources

2,000 views

Published on

Oracle Forms: Data Blocks on Different Sources

Published in: Software
  • Be the first to comment

Oracle Forms: Data Blocks on Different Sources

  1. 1. Data Blocks on Different Data Sources
  2. 2. Objectives • Base a data block on FROM clause sub query • Base a data block on a stored procedure • Return a REF cursor from a stored procedure • Return a table of records from a stored procedure • Select the appropriate data source for a data block
  3. 3. Data source Types A/C No: Branch: Balance: A/C No: Branch: Balance: TableTable Transactional trigger Transactional trigger FROM clause query Stored procedure Query DML Stored procedure
  4. 4. Basing Data Block on a From Clause Query SELECT deptno, Total_salary FROM (SELECT deptno, sum(sal) Total_salary FROM emp GROUP BY deptno) WHERE total_salary>=8000
  5. 5. Why Form Clause Query? Perform joins, lookups, and calculations on the server (thus avoiding multiple network trips) without having to define a view every time. • Improves developer productivity • Reduces the burden on the DBA • Improves performance
  6. 6. Basing a Data block on Stored Procedure for Query Operation Return data by way of: • REF cursor • A Table of records Procedure MARTIN Empno Ename Job 7369 SMITH CLERK 7499 ALLEN SALESMAN 7521 WARD SALESMAN 7566 JONES ANAGER 7654 SALESMAN 7698 BLAKE MANAGER 7782 CLARK MANAGER Querying Emp No Name Job Data Block
  7. 7. Basing a Data block on Stored Procedure for DML Operations • Return data by way of a table of records Procedure MARTIN Empno Ename Job 7369 SMITH CLERK 7499 ALLEN SALESMAN 7521 WARD SALESMAN 7566 JONES ANAGER 7654 SALESMAN 7698 BLAKE MANAGER 7782 CLARK MANAGER Updating Emp No Name Job Data Block
  8. 8. REF Cursor Procedure for Query Define a package specification with: • The objects returned by the REF cursor • The REF cursor • The query procedure: Data returned through the first argument (IN OUT) Define a package body: Write the code for the query procedure
  9. 9. Table of Records Procedure for Query Define a package specification with: • The structure of each row of the table • The table of records • The query procedure: Data returned through the first argument (IN OUT) Define a package body: Write the code for the query procedure
  10. 10. Table of Records Procedure for DML Define a package specification with: • The structure of each row of the table • The table of records • A procedure to insert rows • A procedure to update rows • A procedure to delete rows • A procedure to lock rows Define a package body by writing the code for each DML procedure
  11. 11. Returning a Ref Cursor Query Fetched rows REF cursor REF cursor Procedure SQL SELECT 21 3 4 Emp No Name Job
  12. 12. Returning Table of Records Query Table of Records Cursor Cursor Procedure Any PL/SQL Code 21 3 4 Emp No Name Job
  13. 13. Data Block Wizard Use the Data Block Wizard to specify the following: • Data source type • Query procedure • Insert procedure • Update procedure • Delete procedure • Lock procedure
  14. 14. Data Source Guidelines Base a data block on a FROM clause query to: • Create a “dynamic” view Base a data block on a stored procedure to: • Increase control and security • Specify a SELECT statement at run time • Query or update multiple tables • Perform complex computations • Perform validation and DML on the server side
  15. 15. Data Source Guidelines Query YES YES YES YES YES YES Data Source Table View FROM Clause Proc-Ref Cur Proc-Table Rec Transac. Trigger DML YES YES NO NO YES YES
  16. 16. Summary • Base data blocks on new data sources: – FROM clause query (query only) – Stored procedure (query and DML) • Exploit features of stored procedures : – REF cursors limited to a single SELECT statement – Table of records can be a complex procedure

×