17
12/20/11 Oracle Forms 10g : Demos, Tips and Techniques 1/17 sheik\erbouti.developpe].com/tutoforms10g/tutoforms10g.htm OUacOe FRUPV 10g UeOeaVe 2 : DePRV, TiSV aQd TechQiTXeV Home page 1. IQWURdXcWiRQ HeUe iV a collecWion of OUacle FoUmV 10g Vample dialogV e[WUacWed fUom a compleWe OUacle FoUmV WXWoUial. ThiV WXWoUial haV been ZUiWWen in FUench and iW ZoXld be Woo Wime conVXming Wo WUanVlaWe iW all in EngliVh. ThiV iV Whe UeaVon Zh\ I haYe onl\ e[WUacWed and WUanVlaWed WheVe Vample dialogV. The pXUpoVe of WhiV aUWicle iV noW Wo Weach hoZ Wo bXild a neZ foUm fUom VcUaWch. IW inWendV Wo VhoZ Vome of Whe main adYanced feaWXUeV of Whe pUodXcW. To cleaUl\ XndeUVWand in deWailV hoZ WheVe dialogV ZoUk, \oX Zill haYe Wo open Whem in Whe FoUmV BXildeU and e[amine Whem WhoUoXghl\. HoZeYeU, in WhiV aUWicle, I am going Wo e[plain Whe beVW I can Whe moVW impoUWanW mechaniVmV of each Vample. TheVe Vample haYe been WeVWed ZiWh an OUacle FoUmV 10g UeleaVe 10.1.2.0.2 on an OUacle DaWabaVe 10g E[pUeVV EdiWion ReleaVe 10.2.0.1.0. 2. DeVcUiSWiRQ Rf Whe VaPSOe diaORgV 2.1 MaiQ VcUeeQ TUTO_FORMS.FMB ThiV dialog iV Whe enWU\ poinW of Whe VampleV. Click on a bXWWon Wo VWaUW Whe coUUeVponding dialog. 2.2 CaQYaVeV

Oracle Forms 10g _ Demos, Tips and Techniques

  • Upload
    yatinkv

  • View
    528

  • Download
    43

Embed Size (px)

Citation preview

Page 1: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

1/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

Oracle Forms 10g release 2 : Demos, Tips and Techniques

Home page

1. Introduction

Here is a collection of Oracle Forms 10g sample dialogs extracted from a complete Oracle Forms tutorial.This tutorial has been written in French and it would be too time consuming to translate it all in English.This is the reason why I have only extracted and translated these sample dialogs. The purpose of this article is not to teach how to build a new form from scratch. It intends to show some of the main advanced features of the product. To clearly understand in details how these dialogs work, you will have to open them in the Forms Builder and examine them thoroughly.However, in this article, I am going to explain the best I can the most important mechanisms of each sample. These sample have been tested with an Oracle Forms 10g release 10.1.2.0.2 on an Oracle Database 10g Express Edition Release 10.2.0.1.0.

2. Description of the sample dialogs

2.1 Main screen

TUTO_FORMS.FMB

This dialog is the entry point of the samples. Click on a button to start the corresponding dialog.

2.2 Canvases

Page 2: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

2/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

TEST_CANVAS.FMB

This sample shows three types of canvas :

����������The content canvas (light green)����������The stacked canvas (white)����������The tab canvas (dark green)

Stacked canvasA stacked canvas is displayed atop—or stacked on—the content canvas assigned to the current window. Stacked canvases obscure some part of the underlying content canvas,and often are shown and hidden programmatically. You can display more than one stacked canvas in a window at the same timeA stacked canvas allows to scroll a big canvas in a delimited window.In this sample, the stacked canvas (CV_EMP_1) is twice bigger than its viewport. The <Down> button allows to move the stacked canvas programatically: S e t _ V i e w _ P r o p e r t y ( ' C V _ E M P _ 1 ' , V I E W P O R T _ Y _ P O S _ O N _ C A N V A S , 1 4 0 ) ;

Here are the properties of this stacked canvas: ViewportViewport X position 77Viewport Y position 11Viewport Width 212Viewport Height 138 PhysicalViewport X position on canvas 0Viewport Y position on canvas 0Width 212Height 324 The second Stacked canvas (CV_EMP_3) demonstrates how to integrate in a Tab canvas:

Page 3: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

3/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

2.3 Blocks 2.3.1 Block based on a complex view

TEST_BLOC_VUE.FMB

This sample show how you can base a block on a view that aggregate the columns of several tables (in this case, DEPT and EMP) and when you can insert, update and delete fromthe target tables from this view. The code that handles the target table is located in a program unit, called from the three block-level triggers:

����������ON-INSERT����������ON-UPDATE����������ON-LOCK

This is the code of the ins_upd_emp_dept procedure: P R O C E D U R E i n s _ u p d _ e m p _ d e p t I S

L N $ D u m m y P L S _ I N T E G E R : = 0 ;

B E G I N

- - T a b l e D E P T - -

B e g i n

S e l e c t 1

I n t o L N $ D u m m y

F r o m D U A L

W h e r e e x i s t s ( s e l e c t d e p t n o f r o m d e p t w h e r e d e p t n o = : E M P _ D E P T . D E P T N O ) ;

- - F o u n d - > u p d a t e - -

M e s s a g e ( ' U p d a t e D E P T t a b l e ' ) ;

U P D A T E D E P T

S E T D N A M E = : E M P _ D E P T . D N A M E

W H E R E D E P T N O = : E M P _ D E P T . D E P T N O ;

E x c e p t i o n

W h e n n o _ d a t a _ f o u n d T h e n

- - N o t f o u n d - > i n s e r t - -

M e s s a g e ( ' I n s e r t i n t o D E P T t a b l e ' ) ;

I N S E R T I N T O D E P T ( D E P T N O , D N A M E )

V A L U E S ( : E M P _ D E P T . D E P T N O , : E M P _ D E P T . D N A M E ) ;

E n d ;

- - T a b l e E M P - -

B e g i n

S e l e c t 1

I n t o L N $ D u m m y

F r o m D U A L

W h e r e e x i s t s ( s e l e c t e m p n o f r o m e m p w h e r e e m p n o = : E M P _ D E P T . E M P N O ) ;

- - F o u n d - > u p d a t e - -

M e s s a g e ( ' U p d a t e E M P t a b l e ' ) ;

U P D A T E E M P

S E T E N A M E = : E M P _ D E P T . E N A M E

W H E R E E M P N O = : E M P _ D E P T . E M P N O ;

E x c e p t i o n

W h e n n o _ d a t a _ f o u n d T h e n

- - N o t f o u n d - > i n s e r t - -

M e s s a g e ( ' I n s e r t i n t o E M P t a b l e ' ) ;

I N S E R T I N T O E M P ( E M P N O , E N A M E )

V A L U E S ( : E M P _ D E P T . E M P N O , : E M P _ D E P T . E N A M E ) ;

E n d ;

Page 4: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

4/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

E n d ;

E N D ;

2.3.2 Block based on stored procedures

TEST_BLOC_PROC.FMB

This sample demonstrates how a block can be based on stored procedures.This feature can be implemented in two ways:

����������A REF CURSOR����������A PL/SQL table

In addition to that, there are also two different locations where to implement this functionality:

����������The ON-xxx triggers����������The transactionnal triggers

In this sample, the top block uses a REF CURSOR with the ON-xxx triggersThe bottom block uses a collection with the standard transactionnal triggers. The stored procedures are located in the PKG_EMP package shipped with the scripts. Block1 (EMP), REF CURSOR and ON-xxx triggers

The Query Data Source Type is set to Procedure and the Query Data Source Name indicates the name of the query procedure. The insert, update, delete and lock orders are managed in the corresponding On-xxx triggers: Example of ON-INSERT trigger: D E C L A R E

L R $ E m p e m p _ p k g . e m p _ r e c ;

B E G I N

L R $ E m p . e m p n o : = : e m p . e m p n o ;

L R $ E m p . e n a m e : = : e m p . e n a m e ;

L R $ E m p . j o b : = : e m p . j o b ;

L R $ E m p . s a l : = : e m p . s a l ;

L R $ E m p . c o m m : = : e m p . c o m m ;

e m p _ p k g . e m p _ i n s e r t ( L R $ E m p ) ;

Page 5: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

5/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

e m p _ p k g . e m p _ i n s e r t ( L R $ E m p ) ;

E N D ;

The variable used as parameter is of type of e m p _ p k g . e m p _ r e c

T Y P E e m p _ r e c I S R E C O R D (

e m p n o e m p . e m p n o % T Y P E ,

e n a m e e m p . e n a m e % T Y P E ,

j o b e m p . j o b % T Y P E ,

s a l e m p . s a l % T Y P E ,

c o m m e m p . c o m m % T Y P E ) ;

Then the emp_pkg.emp_insert() stored procedure: - - - - - - - - - - - -

- - I n s e r t - -

- - - - - - - - - - - -

P R O C E D U R E e m p _ i n s e r t ( r I N e m p _ r e c ) I S

B E G I N

I N S E R T I N T O e m p ( e m p n o , e n a m e , j o b , s a l , c o m m )

V A L U E S ( r . e m p n o , r . e n a m e , r . j o b , r . s a l , r . c o m m ) ;

E N D e m p _ i n s e r t ;

Block2 (EMP_TRG), Collection and transactionnal triggers

This block uses a collection of records with the emp.pkg.emp_query procedure. T Y P E e m p t a b I S T A B L E O F e m p _ r e c I N D E X B Y B I N A R Y _ I N T E G E R ;

P R O C E D U R E e m p _ q u e r y ( e m p _ d a t a I N O U T e m p t a b ) I S

i i N U M B E R ;

C U R S O R e m p s e l e c t I S

S E L E C T e m p n o , e n a m e , j o b , s a l , c o m m F R O M e m p

O R D E R B Y e n a m e ;

B E G I N

O P E N e m p s e l e c t ;

i i : = 1 ;

L O O P

F E T C H e m p s e l e c t I N T O

e m p _ d a t a ( i i ) . e m p n o ,

e m p _ d a t a ( i i ) . e n a m e ,

e m p _ d a t a ( i i ) . j o b ,

e m p _ d a t a ( i i ) . s a l ,

e m p _ d a t a ( i i ) . c o m m ;

E X I T W H E N e m p s e l e c t % N O T F O U N D ;

i i : = i i + 1 ;

E N D L O O P ;

E N D e m p _ q u e r y ;

The collection of records is an IN OUT parameter, read from the database and returned to Forms. The insert, update,delete and lock orders are also managed by stored procedures.(see them in detail in the EMP_PKG package)

Have also a look at the Query Data Source Column property that manages the relation between the columns of the collection and the items of the block.

Page 6: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

6/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

2.3.3 Block based on a relational table that contains a collection

TEST_COLLECTION.FMB

In this dialog, we can see how to handle a table that contains a nested table (collection).There is no standard buit-in to base a block on a collection, but we will see how easy it is to work with this sort of object via the ON-xxx triggers. Here is the description of the table (ARTICLES) C R E A T E T A B L E A R T I C L E S

( C O D E V A R C H A R 2 ( 2 0 B Y T E ) ,

L I B E L L E V A R C H A R 2 ( 1 0 0 B Y T E ) ,

P R I X N U M B E R ( 8 , 2 ) ,

Q T E T O T N U M B E R ( 8 , 0 ) ,

C A S E S T A B _ T Y P _ C A S E

)

N E S T E D T A B L E C A S E S S T O R E A S C A S E S _ N T

R E T U R N A S V A L U E ;

TAB_TYP_CASE is a table of objects of type : TYP_CASE c r e a t e o r r e p l a c e T Y P E T Y P _ C A S E A S O B J E C T

(

E M P V A R C H A R 2 ( 1 0 ) ,

Q T E N U M B E R

)

In this sample, the first block (ARTICLES) displays the standard columns of the ARTICLE table and the second block (detail) displays the columns of its nested table. Populate the detail block (nested table) The detail block (CASES) is dynamically populated each time a master record change in a When-New-Record-Instance of the master block: D e c l a r e

L C $ R e q V a r c h a r 2 ( 2 5 6 ) ;

B e g i n

I f : A R T I C L E S . C O D E I s n o t n u l l T h e n

- - D y n a m i c q u e r y o f s e c o n d a r y b l o c k - -

L C $ R e q : = ' ( S E L E C T c a s e s . E M P , c a s e s . Q T E F R O M T A B L E ( S E L E C T c a s e s F R O M a r t i c l e s W H E R E c o d e = ' ' ' | | : A R T I C L E S . C O D E | | ' ' ' ) c a s e s ) ' ;

G o _ B l o c k ( ' C A S E S ' ) ;

C l e a r _ B l o c k ;

S e t _ B l o c k _ P r o p e r t y ( ' C A S E S ' , Q U E R Y _ D A T A _ S O U R C E _ N A M E , L C $ R e q ) ;

- - p o p u l a t e t h e b l o c k - -

E x e c u t e _ Q u e r y ;

G o _ B l o c k ( ' A R T I C L E S ' ) ;

E l s e

G o _ B l o c k ( ' C A S E S ' ) ;

C l e a r _ B l o c k ;

G o _ B l o c k ( ' A R T I C L E S ' ) ;

Page 7: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

7/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

G o _ B l o c k ( ' A R T I C L E S ' ) ;

E n d i f ;

E n d ; Because it is not possible to create a new article with a NULL collection, we have to handle the insertion into the ARTICLE table in a ON-INSERT trigger: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - w e a r e d o i n g a n e x p l i c i t i n s e r t b e c a u s e t h e n e w r e c o r d - -

- - c a n n o t c o n t a i n a N U L L c o l l e c t i o n - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I N S E R T I N T O A R T I C L E S

(

C O D E ,

L I B E L L E ,

P R I X ,

Q T E T O T ,

C A S E S

)

V A L U E S

(

: A R T I C L E S . C O D E ,

: A R T I C L E S . L I B E L L E ,

: A R T I C L E S . P R I X ,

: A R T I C L E S . Q T E T O T ,

T A B _ T Y P _ C A S E ( ) - - i n s e r t a n e m p t y c o l l e c t i o n

)

;

Indeed, if we insert a NULL collection, it will be no longer possible to insert anything in the nested table. Then after, it is easy to manage the detail records with the ON-xxx triggers of the CASES block: ON-INSERT: - - I n s e r t t h e r o w i n t h e c o l l e c t i o n - -

I N S E R T I N T O T A B L E

(

S E L E C T

c a s e s

F R O M

a r t i c l e s

W H E R E

c o d e = : A R T I C L E S . C O D E

)

V a l u e s

(

T Y P _ C A S E ( : C A S E S . E M P , : C A S E S . Q T E )

) ;

ON-DELETE: - - D e l e t e r o w i n t h e c o l l e c t i o n - -

D E L E T E F R O M T A B L E

(

S E L E C T

c a s e s

F R O M

a r t i c l e s

W H E R E

c o d e = : A R T I C L E S . C O D E

) c a s e s

W H E R E

c a s e s . e m p = : C A S E S . E M P

;

etc.

2.3.4 Block based on multiple data sources

Page 8: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

8/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

TEST_DATA_SOURCES.FMB

I this sample dialog, we can see how to base a block on several tables that share an identical structure.(see the JANVIER, FEVRIER and MARS tables created by the install.sql script) The list item is populated with the name of three tables that share the same structure:

Then, the source table of the block is changed dynamically in the When-List-Changed trigger: I f : C T R L . C H O I X i s n o t n u l l T h e n

: g l o b a l . c h o i x : = : c t r l . c h o i x ;

c l e a r _ f o r m ;

: c t r l . c h o i x : = : g l o b a l . c h o i x ;

- - c h a n g e t h e Q u e r y D a t a S o u r c e - -

S e t _ B l o c k _ P r o p e r t y ( ' T E S T 2 ' , Q U E R Y _ D A T A _ S O U R C E _ N A M E , : g l o b a l . C H O I X ) ;

g o _ b l o c k ( ' T E S T 2 ' ) ;

e x e c u t e _ q u e r y ;

E n d i f ;

2.3.5 Block based on an object table that contains a collection of references

Page 9: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

9/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

TEST_OBJETS.FMB

Let’s see how to manage an object table that contains a collection of references. This sample is based on the object table (ARTICLE_OBJ) that contains a collection of references: c r e a t e o r r e p l a c e T Y P E R E F _ T Y P _ E M P A S O B J E C T

(

r e f _ e m p R E F T Y P _ E M P

)

c r e a t e o r r e p l a c e T Y P E T A B _ R E F _ T Y P _ E M P A S T A B L E O F R E F _ T Y P _ E M P

c r e a t e o r r e p l a c e T Y P E T Y P _ A R T I C L E S A S O B J E C T

(

C O D E V A R C H A R 2 ( 2 0 ) ,

L I B E L L E V A R C H A R 2 ( 1 0 0 ) ,

P R I X N U M B E R ( 8 , 2 ) ,

Q T E T O T N U M B E R ( 8 ) ,

R E M P T A B _ R E F _ T Y P _ E M P - - c o l l e c t i o n

)

C R E A T E T A B L E A R T I C L E S _ O B J O F T Y P _ A R T I C L E S

N E S T E D T A B L E R E M P S T O R E A S R E M P _ N T

R E T U R N A S V A L U E ;

The tip is the same that the one used to manage the relational table with nested table: - A when-New-Record-Instance trigger on the master block to populate the detail block (the collection of references): D e c l a r e

L C $ R e q V a r c h a r 2 ( 2 5 6 ) ;

B e g i n

I f : A R T I C L E S . C O D E I s n o t n u l l T h e n

- - D y n a m i c q u e r y o f s e c o n d a r y b l o c k - -

L C $ R e q : = ' ( S E L E C T e m p . r e f _ e m p . e m p E M P , e m p . r e f _ e m p . q t e Q T E

F R O M T A B L E ( S E L E C T R E M P F R O M a r t i c l e s _ o b j W H E R E C O D E = ' ' ' | | : A R T I C L E S . C O D E | | ' ' ' ) e m p

W H E R E e m p . r e f _ e m p . a r t = ' ' ' | | : A R T I C L E S . C O D E | | ' ' ' ) ' ;

G o _ B l o c k ( ' C A S E S ' ) ;

C l e a r _ B l o c k ;

- - c h a n g e t h e Q u e r y D a t a S o u r c e N a m e - -

S e t _ B l o c k _ P r o p e r t y ( ' C A S E S ' , Q U E R Y _ D A T A _ S O U R C E _ N A M E , L C $ R e q ) ;

- - p o p u l a t e t h e b l o c k - -

E x e c u t e _ Q u e r y ;

G o _ B l o c k ( ' A R T I C L E S ' ) ;

E l s e

G o _ B l o c k ( ' C A S E S ' ) ;

C l e a r _ B l o c k ;

G o _ B l o c k ( ' A R T I C L E S ' ) ;

E n d i f ;

E n d ; - An ON-INSERT trigger to insert a new record with an empty collection: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - W e a r e d o i n g a n i m p l i c i t i n s e r t b e c a u s e t h e n e w - -

- - r e c o r d c a n n o t c o n t a i n a N U L L c o l l e c t i o n - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I N S E R T I N T O A R T I C L E S _ O B J

Page 10: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

10/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

I N S E R T I N T O A R T I C L E S _ O B J

V A L U E S

(

T Y P _ A R T I C L E S

(

: A R T I C L E S . C O D E ,

: A R T I C L E S . L I B E L L E ,

: A R T I C L E S . P R I X ,

: A R T I C L E S . Q T E T O T ,

T A B _ R E F _ T Y P _ E M P ( )

)

) ;

The collection of references is managed with the corresponding ON-xxx trigger of the detail block: ON-INSERT: - - I n s e r t a r o w ( R E F ) i n t h e c o l l e c t i o n - -

D e c l a r e

L C $ R e q V a r c h a r 2 ( 2 5 6 ) ;

B e g i n

L C $ R e q : = ' I N S E R T I N T O T A B L E

( S E L E C T r e m p F R O M A R T I C L E S _ O B J W H E R E c o d e = ' ' ' | | : A R T I C L E S . C O D E | | ' ' ' )

V A L U E S

( R E F _ T Y P _ E M P ( ( S E L E C T R E F ( a ) F R O M E M P _ O B J a W H E R E a . A R T = ' ' '

| | : A R T I C L E S . C O D E | | ' ' ' A N D a . E M P = ' ' ' | | : C A S E S . E M P | | ' ' ' ) ) ) ' ;

F o r m s _ D d l ( L C $ R e q ) ;

E n d ;

ON-DELETE: - - D e l e t e t h e r o w ( R E F ) o f t h e c o l l e c t i o n - -

D E L E T E F R O M T A B L E

( S E L E C T r e m p F R O M A R T I C L E S _ O B J W H E R E c o d e = : A R T I C L E S . C O D E ) e m p

W H E R E

e m p . r e f _ e m p . a r t = : A R T I C L E S . C O D E

A n d

e m p . r e f _ e m p . e m p = : C A S E S . E M P

;

2.4 Items 2.4.1 Principal items

TEST_ITEMS.FMB

Here is a description of the main items.Click everywhere on each item to see some information messages and some particular behaviours.

2.4.2 List items

Page 11: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

11/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

2.4.2 List items

TEST_LISTES.FMB

Let’s study and handle the three sorts of list item and also the different ways to populate them.In this sample, the three list items are synchronized. Change the value of the first list and it will adapt the content of the second then the content of the third. For each new list value, the corresponding value and label are displayed. a) The first list item is populated with the RG_MOIS record group: - - L i s t 1 - -

e r r c o d e : = P o p u l a t e _ G r o u p ( ' R G _ M O I S ' ) ;

C L E A R _ L I S T ( ' B L O C 2 . L I S T E 1 ' ) ;

P O P U L A T E _ L I S T ( ' B L O C 2 . L I S T E 1 ' , ' R G _ M O I S ' ) ;

- - S e l e c t t h e f i r s t v a l u e - -

: B L O C 2 . L I S T E 1 : = G e t _ L i s t _ E l e m e n t _ V a l u e ( ' B L O C 2 . L I S T E 1 ' , 1 ) ;

b) Then init the second list item - - U p d a t e t h e w e e k s l i s t - -

e r r c o d e : = P o p u l a t e _ G r o u p ( ' R G _ S E M A I N E S ' ) ;

C L E A R _ L I S T ( ' B L O C 2 . L I S T E 2 ' ) ;

P O P U L A T E _ L I S T ( ' B L O C 2 . L I S T E 2 ' , ' R G _ S E M A I N E S ' ) ;

- - S e l e c t t h e f i r s t v a l u e - -

: B L O C 2 . L I S T E 2 : = G e t _ L i s t _ E l e m e n t _ V a l u e ( ' B L O C 2 . L I S T E 2 ' , 1 ) ;

c) That finally init the third list item: P R O C E D U R E I n i t _ L i s t e 3 I S

L C $ D V a r c h a r 2 ( 1 2 ) ;

L C $ D a y V a r c h a r 2 ( 2 0 ) ;

B E G I N

- - U p d a t e t h e d a y s l i s t - -

L C $ D : = ' 0 1 / 0 1 / 2 0 0 5 ' ;

C l e a r _ L i s t ( ' B L O C 2 . L I S T E 3 ' ) ;

F o r i I N 0 . . 6 L o o p

S E L E C T

t o _ c h a r ( T o _ d a t e ( L C $ D , ' D D / M M / Y Y Y Y ' ) + ( i + ( ( T o _ n u m b e r ( : B L O C 2 . L I S T E 2 ) - 1 ) * 7 ) ) , ' F M D a y D D M o n t h ' )

I n t o

L C $ D a y

F R O M d u a l ;

A d d _ L i s t _ E l e m e n t ( ' B L O C 2 . L I S T E 3 ' , i + 1 , L C $ D a y , L C $ D a y ) ;

E n d l o o p ;

- - S e l e c t t h e f i r s t v a l u e - -

: B L O C 2 . L I S T E 3 : = G e t _ L i s t _ E l e m e n t _ V a l u e ( ' B L O C 2 . L I S T E 3 ' , 1 ) ;

E x c e p t i o n

W h e n O t h e r s t h e n

N u l l ;

E N D ;

2.4.3 Image items

Page 12: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

12/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

ALBUM_PHOTO.FMB

This dialog is the main part of the ensemble that allows to search, attach and display images. You can build a photo album based on a one image’s column table. C R E A T E T A B L E P H O T O S

( L E G E N D E V A R C H A R 2 ( 1 0 0 B Y T E ) ,

P H O T O B L O B N O T N U L L E N A B L E ,

F O R M A T V A R C H A R 2 ( 5 0 B Y T E ) N O T N U L L E N A B L E ,

C R E D I T V A R C H A R 2 ( 5 0 B Y T E ) N O T N U L L E N A B L E , L I E N V A R C H A R 2 ( 1 0 0 B Y T E ) ,

I D E N T I F I A N T N U M B E R ( 5 , 0 ) N O T N U L L E N A B L E ,

N O M V A R C H A R 2 ( 5 0 B Y T E ) ,

C O N S T R A I N T P H O T O _ P K P R I M A R Y K E Y ( I D E N T I F I A N T ) E N A B L E

) ;

It shows two ways to search a filename on the local machine with and without Webutil. By clicking on a picture, you can navigate on another canvas to display the detail of the picture:

Page 13: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

13/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

CHARGE_PHOTO.FMB

The get_file_name sample dialog is only a “pure exercice of style” , because it is so easy to pick-up a file with the File_Open_Dialog() Webutil function.This sample is interesting to see how to use the HOST() and TEXT_IO() functions to get the list of the local machine drives and their content.

CHARGE_PHOTO_WEBUTIL.FMB

Another dialog to store the picture and its properties.

2.4.4 Java Bean component

Page 14: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

14/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

TEST_GRAPH.FMB

Here is a sample to demonstrate how to handle a bean area.This dialog use the Oracle FormsGraph Java Bean that is part of the Oracle Forms demos. You can download the FormsGraph.jar file on the OTN pagehttp://www.oracle.com/technology/sample_code/products/forms/files/formsgraph_patch2005.zip

2.4.5 Calculated items

TESTS_CALCUL.FMB

Let’s see how to use the calculated items. The first calculated item use the Summary calculation mode:

The third one use a Formula calculation mode

Page 15: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

15/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

2.5 Alerts

TEST_ALERTES_MESSAGES.FMB

This dialog shows how to use the Alert boxes to build the messaging engine of your Forms application. The message texts are read from the database then displayed via Alert boxes.To reduce the number of messages needed in the application, some of them can take from 1 up to 3 parmeters (%1, %2 and %3). A pipe (|) character allows to split the messageon several lines. The main block is based on the MESSAGES table.

C R E A T E T A B L E M E S S A G E S

( C O D E N U M B E R ( 5 , 0 ) N O T N U L L E N A B L E , - - u n i q u e i d e n t i f i a n t

T E X T E V A R C H A R 2 ( 2 5 6 ) N O T N U L L E N A B L E , - - t e x t o f t h e m e s s a g e

T I T R E V A R C H A R 2 ( 1 0 0 ) , - - t i t l e o f t h e a l e r t

S T O P V A R C H A R 2 ( 1 ) D E F A U L T ' N ' N O T N U L L E N A B L E , - - S h a l l w e s t o p t h e p r o c e s s ? ( r a i s e f o r m _ t r i g g e r _ f a i l u r e )

A L E R T E V A R C H A R 2 ( 1 5 ) , - - n a m e o f t h e a l e r t b o x C O N S T R A I N T M S G _ P K P R I M A R Y K E Y ( C O D E ) E N A B L E

)

This sample use the Affiche_Message() procedure of the TUTO_FORMS pl/sql library to display the messages.These messages can be displayed through the 3 alert boxes available in every dialog of this demo.

����������AL_ERREUR wich is the simple “OK” alert box.����������AL_MSG_OUI_NON wich is a yes/no alert box (default yes)����������AL_MSG_NON_OUI wich is a yes/no alert box (default no)

2.6 Property classes and visual attributes

Page 16: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

16/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

TEST_CLASSES_PROP.FMB

Let’s see some ways to use the property classes and the visual attributes to colorize and highlight dynamically different objects of the form (alert, item, current record, etc.).Property classes and visual attributes are located in the OBJ_TUTO_FORMS.olb object library. 2.7 Forms internal triggering events

TEST_CYCLES.FMB

This dialog allows you to understand what trigger fire and in what order when you use the application. Before each particular action, you can clear the list of triggers window.This window show you what trigger is firing in what order and from what block and what item.

3. Installation steps

This sample dialog need database objects to run.All the necessary objects are provided in the tutoforms10g.zip file shipped with the article. This zip file contains 2 sub directories: /config that contains the configuration files./scripts that contains the Sql script files to create the database objects.

����������Download the tutoforms10g.zip file

����������Unzip the tutoforms10g.zip file under your <DEVSUITE_HOME>/forms/ directory.

����������Create a new user in your database

Page 17: Oracle Forms 10g _ Demos, Tips and Techniques

12/20/11 Oracle Forms 10g : Demos, Tips and Techniques

17/17sheikyerbouti.developpez.com/tutoforms10g/tutoforms10g.htm

����������With Sql*plus or SqlDeveloper, run the /scripts/install.sql script

note : because this demo use the Webutil functions, the Oracle user where you have created these objects must have the W E B U T I L _ D B package compiled or a grant

EXECUTE to this package if it is present in another schema.

����������Under the /tutoforms/ directory compile all the source modulesYou can use the compile_all.bat file located in the same directory to compile all objects at once. e.g. c o m p i l e _ a l l u s e r / p a s s w o r d @ i n s t a n c e

����������Edit the /tutoforms/config/tutforms10g.env file to indicate your own settings (in blue in this example)

#oracle home adapt this value to your own settingORACLE_HOME=D:\Dev10gR2 FORMS_PATH=%ORACLE_HOME%\forms\tutoformsORACLE_PATH=%ORACLE_HOME%\forms\tutoformsFORMS_TRACE_PATH=%ORACLE_HOME%\forms\tutoformsCLASSPATH=D:\Dev10gR2\forms\java\frmwebutil.jar;%ORACLE_HOME%\jlib\debugger.jar;%ORACLE_HOME%\forms\tutoforms\FormsGraph.jar;%ORACLE_HOME%\forms\tutoforms\myIcons.jar;

# webutil config file pathWEBUTIL_CONFIG=D:\Dev10gR2\forms\server\webutil.cfg

����������Edit the /tutoforms/config/ add_to_formsweb.cfg file to set your own database connect string (in blue in this example)

...lookAndFeel=OraclecolorScheme=blaflogo=no#don't forget to put your own database connexionuserid=tutoforms10g/tutoforms10g@XE

����������Copy the /tutoforms/config/tutforms10g.env to the /forms/server directory

����������add the /tutoforms/config/ add_to_formsweb.cfg at the end of your /forms/server/formsweb.cfg file

����������Then, you can start the demo by indicating the new [tutoforms10g] formsweb.cfg section.

http://machine:8890/forms/frmservlet?config=tutoforms10g