Copyright  Oracle Corporation, 1998. All rights reserved. 5 More on Creating Database Forms Using AppBuilder.

Slides:



Advertisements
Similar presentations
Copyright  Oracle Corporation, All rights reserved. 3 Displaying Data from Multiple Tables.
Advertisements

Copyright  Oracle Corporation, All rights reserved. 3 JavaBeans: Reusing Application Components.
Copyright  Oracle Corporation, All rights reserved. 2 Java and Databases: An Overview.
Copyright  Oracle Corporation, All rights reserved. 1 Creating an Application: The AppBuilder for Java IDE.
1Eyad Alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
Copyright  Oracle Corporation, All rights reserved. 6 Writing Correlated Subqueries.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
ACCESS PART 2. Objectives Database Tables Table Parts Key Field Query and Reports Import from Excel Link to Excel.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Writing Basic SQL statement 2 July July July Create By Pantharee Sawasdimongkol.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
1 Chapter 5: Introduction To Form Builder. 2 Forms  Why Do We Use Form Builder?  Why Don’t We Use SQL Only?!
Copyright  Oracle Corporation, All rights reserved. 4 Creating Functions.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
6 Copyright © 2004, Oracle. All rights reserved. Working with Data Blocks and Frames.
Copyright  Oracle Corporation, All rights reserved. I Introduction.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
Copyright  Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
4-1 Copyright  Oracle Corporation, All rights reserved. Displaying Data from Multiple Tables.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
2 Writing Basic SELECT Statements. 1-2 Copyright  Oracle Corporation, All rights reserved. Capabilities of SQL SELECT Statements Selection Projection.
Copyright  Oracle Corporation, All rights reserved. Writing Basic SQL Statements.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
Copyright  Oracle Corporation, All rights reserved. 4 Accessing a Database Using JBCL.
RELATSIOONILISED ANDMEBAASID(alg) SQLi VÕIMALUSED.
SQL- DQL (Oracle Version). 2 SELECT Statement Syntax SELECT [DISTINCT] column_list FROM table_list [WHERE conditional expression] [GROUP BY column_list]
Copyright  Oracle Corporation, All rights reserved. 6 Accessing a Database Using the JDBC API.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros.
Copyright  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
What are queries? Queries are a way of searching for and compiling data from one or more tables. Running a query is like asking a detailed question of.
8 Producing Readable Output with SQL*Plus. 8-2 Objectives At the end of this lesson, you should be able to: Produce queries that require an input variable.
Copyright  Oracle Corporation, All rights reserved. 18 Interacting with the Oracle Server.
Copyright س Oracle Corporation, All rights reserved. 4 Displaying Data from Multiple Tables.
Copyright  Oracle Corporation, All rights reserved. 11 Including Constraints.
1 Writing Basic SQL Statements. 1-2 Objectives At the end of this lesson, you should be able to: List the capabilities of SQL SELECT statements Execute.
I-1 Copyright س Oracle Corporation, All rights reserved. Data Retrieval.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Copyright  Oracle Corporation, All rights reserved. 8 Producing Readable Output with SQL*Plus.
23 Copyright © 2009, Oracle. All rights reserved. Oracle Business Intelligence Answers: Advanced Features.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
1-1 Copyright  Oracle Corporation, All rights reserved. Logging In to SQL*Plus From Windows environment:From Windows environment: From command line:From.
22 Copyright © 2009, Oracle. All rights reserved. Filtering Requests in Oracle Business Intelligence Answers.
CHAPTER 7 LESSON C Creating Database Reports. Lesson C Objectives  Display image data in a report  Manually create queries and data links  Create summary.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
Copyright Ó Oracle Corporation, All rights reserved. 77 Creating LOVs and Editors.
Writing Basic SQL Statements. Objectives After completing this lesson, you should be able to do the following: –List the capabilities of SQL SELECT statements.
19 Copyright © 2004, Oracle. All rights reserved. Coding PL/SQL Triggers.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
Database (Microsoft Access). Database A database is an organized collection of related data about a specific topic or purpose. Examples of databases include:
1 Chapter 6: Creating Oracle Data Block Forms. 2 Forms  Application with a graphical user interface that looks like a paper form  Used to insert, update,
Copyright  Oracle Corporation, All rights reserved. 4 Displaying Data from Multiple Tables.
Displaying Data from Multiple Tables. Objectives After completing this lesson, you should be able to do the following: –Write SELECT statements to access.
4 Displaying Data from Multiple Tables. 4-2 Objectives At the end of this lesson, you should be able to: Write SELECT statements to access data from more.
Copyright س Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
CHAPTER 7 LESSON B Creating Database Reports. Lesson B Objectives  Describe the components of a report  Modify report components  Modify the format.
Displaying Data from Multiple Tables
Displaying Data from Multiple Tables
This shows the user interface and the SQL Select for a situation with two criteria in an AND relationship.
Writing Correlated Subqueries
Displaying Data from Multiple Tables
Presentation transcript:

Copyright  Oracle Corporation, All rights reserved. 5 More on Creating Database Forms Using AppBuilder

Copyright  Oracle Corporation, All rights reserved. 5-2 Objectives After completing this lesson, you should be able to do the following: Create master-detail forms Use JBCL components programmatically in Java code Filter and sort data records Use data modules, and perform parameterized queries After completing this lesson, you should be able to do the following: Create master-detail forms Use JBCL components programmatically in Java code Filter and sort data records Use data modules, and perform parameterized queries

Copyright  Oracle Corporation, All rights reserved. 5-3 Master-Detail Relationships LOC NEW YORK DALLAS CHICAGO BOSTON DEPTNO DNAME ACCOUNTING RESEARCH SALES OPERATIONS Master table, DEPT EMPNO ENAME KING CLARK MILLER JONES FORD Details table, EMP DEPTNO 10 20

Copyright  Oracle Corporation, All rights reserved. 5-4 Master-Detail Form at Run Time This is how the Master-Detail form will appear at run time Master section Detail section This is how the Master-Detail form will appear at run time Master section Detail section

Copyright  Oracle Corporation, All rights reserved. 5-5 Two or more QueryDataSets are required in a master-detail form Specifying QueryDataSet Properties Detail query Master query

Copyright  Oracle Corporation, All rights reserved. 5-6 Establishing the Master-Detail Relationship Specify masterLink property in detail QueryDataSet

Copyright  Oracle Corporation, All rights reserved. 5-7 Connecting the Master Query to the Detail Query This column in the master query … … is linked to this column in the detail query

Copyright  Oracle Corporation, All rights reserved. 5-8 Data-aware controls can now be added to display the fields Fields attached to master query Fields attached to detail query Data-aware controls can now be added to display the fields Fields attached to master query Fields attached to detail query Using the Master and Detail QueryDataSets

Copyright  Oracle Corporation, All rights reserved. 5-9 Delayed Fetching Delayed fetching can improve performance Data in the “details” data set is fetched only when needed Select “Delay fetch…” check box in masterLink editor A WHERE clause is required in the SQL string of the detail QueryDataSet Delayed fetching can improve performance Data in the “details” data set is fetched only when needed Select “Delay fetch…” check box in masterLink editor A WHERE clause is required in the SQL string of the detail QueryDataSet

Copyright  Oracle Corporation, All rights reserved Calculated Columns It is also possible to define calculated columns in a QueryDataSet ENAME KING CLARK MILLER ANNUAL_SAL SAL

Copyright  Oracle Corporation, All rights reserved Adding a Calculated Column to a QueryDataSet 1.Select in the QueryDataSet 2. Open Inspector window 3.Set calcType field to calculated 4. Set columnName and dataType 1.Select in the QueryDataSet 2. Open Inspector window 3.Set calcType field to calculated 4. Set columnName and dataType

Copyright  Oracle Corporation, All rights reserved Supplying a Value for a Calculated Field When a calculated field needs evaluation: QueryDataSet component generates a calcFields event You must handle this event When a calculated field needs evaluation: QueryDataSet component generates a calcFields event You must handle this event

Copyright  Oracle Corporation, All rights reserved Guided Practice: Providing calcFields Handler Method Explain the following handler method: import java.math.BigDecimal; // Standard class … void queryDetail_calcFields(ReadRow readRow, DataRow dataRow, boolean boolean1) … { BigDecimal sal, ann; sal = readRow.getBigDecimal("SAL"); ann = sal.multiply(new BigDecimal(12)); dataRow.setBigDecimal("ANNUAL_SAL", ann); }

Copyright  Oracle Corporation, All rights reserved Calculated Columns at Run Time The GridControl displays the calculated column automatically Calculated column The GridControl displays the calculated column automatically Calculated column

Copyright  Oracle Corporation, All rights reserved Filtering Rows If required, a filter can be defined for a QueryDataSet Example: Filter employees earning less than a certain amount If required, a filter can be defined for a QueryDataSet Example: Filter employees earning less than a certain amount

Copyright  Oracle Corporation, All rights reserved QueryDataSets Generate filterRow Events A filterRow event is generated before each row is added to the data set You provide a handler method, to decide whether to keep or reject the row A filterRow event is generated before each row is added to the data set You provide a handler method, to decide whether to keep or reject the row

Copyright  Oracle Corporation, All rights reserved Supplying a Handler Method to Filter Rows void queryDetail_filterRow( ReadRow readRow, RowFilterResponse rowFilterResponse)… { String txt = txtMinSal.getText(); if (txt.equals("")) txt = "0.0"; BigDecimal min = new BigDecimal(txt); BigDecimal sal = readRow.getBigDecimal("SAL"); if (sal.compareTo(min) >= 0) rowFilterResponse.add(); }

Copyright  Oracle Corporation, All rights reserved Forcing a Row Filter to Occur void btn_actionPerformed(ActionEvent e) { try { queryDetail.refilter(); } catch(DataSetException dse) {} } Call refilter() to force rows to be refiltered

Copyright  Oracle Corporation, All rights reserved Sorting Rows A data set can be dynamically re-sorted at any time Example: ChoiceControl can specify the sort column A data set can be dynamically re-sorted at any time Example: ChoiceControl can specify the sort column

Copyright  Oracle Corporation, All rights reserved Performing a Sort Programmatically void choiceControl1_itemStateChanged(ItemEvent e){ String[] s = new String[1]; s[0] = choiceControl1.getSelectedItem(); SortDescriptor sd; sd = new SortDescriptor(s, true, false); try { queryDetail.close(); queryDetail.setSort(sd); queryDetail.open(); } catch (DataSetException dse) {} }

Copyright  Oracle Corporation, All rights reserved Practice 5-1 Overview Define a master-detail form Add a calculated column to a QueryDataSet Add a filter to a QueryDataSet Add sort capabilities to a QueryDataSet Define a master-detail form Add a calculated column to a QueryDataSet Add a filter to a QueryDataSet Add sort capabilities to a QueryDataSet

Copyright  Oracle Corporation, All rights reserved The Bigger Picture The programs we have seen so far comprise a single applet The applet contains the Database and QueryDataSet components The programs we have seen so far comprise a single applet The applet contains the Database and QueryDataSet components database1 queryDataSet1 queryDataSet2 Java applet

Copyright  Oracle Corporation, All rights reserved Working with Larger Programs Complex programs can have many frames Each frame may need its own Database and QueryDataSet components Complex programs can have many frames Each frame may need its own Database and QueryDataSet components database1 queryDataSet1 queryDataSet2 Java applet database1 queryDataSet1 queryDataSet2 Frame 1 database1 queryDataSet1 queryDataSet2 Frame 2

Copyright  Oracle Corporation, All rights reserved The Benefit of Data Modules To avoid duplication, data components can be placed in a shared Data Module database1 queryDataSet1 queryDataSet2 Data module Applet Frame 1 Frame 2 queryDataSet3

Copyright  Oracle Corporation, All rights reserved Creating a Data Module in AppBuilder Select File— >New, and double-click the Data Module icon Fill in details for the new data module

Copyright  Oracle Corporation, All rights reserved Adding Components to a Data Module Add shared Database and QueryDataSet components to the data module

Copyright  Oracle Corporation, All rights reserved Linking an Applet to a Data Module Applets can be linked to a data module, as follows: Data module automatically added to Structure Pane Applets can be linked to a data module, as follows: Data module automatically added to Structure Pane public class MyApplet extends Applet { MyDataModule dm = MyDataModule.getDataModule(); XYLayout xYLayout1 = new XYLayout(); // Etc … };

Copyright  Oracle Corporation, All rights reserved Designing the Applet User Interface Data-aware controls can be added to the applet, as usual The QueryDataSet is now located in the data module Data-aware controls can be added to the applet, as usual The QueryDataSet is now located in the data module

Copyright  Oracle Corporation, All rights reserved Adding a Frame to Display Orders Information Select File—>New, and double-click the Frame icon Fill in details for the new frame

Copyright  Oracle Corporation, All rights reserved Linking a Frame to a Data Module Frames are linked to a data module in exactly the same way as for applets: Data module automatically added to the Structure Pane Frames are linked to a data module in exactly the same way as for applets: Data module automatically added to the Structure Pane public class MyFrame extends DecoratedFrame { MyDataModule dm = MyDataModule.getDataModule(); XYLayout xYLayout1 = new XYLayout(); // Etc … };

Copyright  Oracle Corporation, All rights reserved Specifying a SQL String to Populate the Frame Our frame will display all the orders made by a selected customer Define a separate QueryDataSet to perform this query Place this query in the data module Our frame will display all the orders made by a selected customer Define a separate QueryDataSet to perform this query Place this query in the data module select ORDID, ORDERDATE, SHIPDATE, TOTAL from ORD where CUSTID = :currCust

Copyright  Oracle Corporation, All rights reserved Defining Parameterized Rows The Orders query takes a parameter to specify the current customer This parameter must be represented by a ParameterRow object: The Orders query takes a parameter to specify the current customer This parameter must be represented by a ParameterRow object: void jbInit() … { // Code in MyDataModule ParameterRow pr = new ParameterRow(); pr.addColumn("currCust", Variant.BIGDECIMAL); pr.setBigDecimal("currCust", new BigDecimal(0)); queryOrders.setQuery( new QueryDescriptor(…, pr, true, false)); }

Copyright  Oracle Corporation, All rights reserved Executing the Orders Query void btnControl1_actionPerformed(ActionEvent e) { try { QueryDataSet qc = dm.getQueryCustomers(); BigDecimal custid = qc.getBigDecimal("CUSTID"); QueryDataSet qo = dm.getQueryOrders(); ReadWriteRow pr = qo.getParameterRow(); pr.setBigDecimal("currCust", custid); qo.executeQuery(); new MyFrame().show(); } catch(DataSetException dse) {} }

Copyright  Oracle Corporation, All rights reserved Putting It All Together

Copyright  Oracle Corporation, All rights reserved Summary Master-detail forms can be defined, using the masterLink property Calculated columns can be added to a data set Rows can be filtered and sorted In large programs, a data module can be used for shared components Parameterized queries can be used to specify query values at run time Master-detail forms can be defined, using the masterLink property Calculated columns can be added to a data set Rows can be filtered and sorted In large programs, a data module can be used for shared components Parameterized queries can be used to specify query values at run time

Copyright  Oracle Corporation, All rights reserved Practice 5-2 Overview Define a data module Attach a panel to the data module, and add the panel to an applet Attach a frame window to the data module Launch the frame window from the applet Define a data module Attach a panel to the data module, and add the panel to an applet Attach a frame window to the data module Launch the frame window from the applet

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices

Copyright  Oracle Corporation, All rights reserved Full Notes Page for Practices