Friday, September 21, 2012

Trigger for Switchboard (Button Link to Page)


Right click Course Information button > PL/SQL Editor> WHEN-MOUSE-CLICK


open_form ('c:\Temp\oracle_forms\COURSE.fmx', ACTIVATE, SESSION);
*change path to where the COURSE.fmx located.
*COURSE.fmx not COURSE.fmb

Button SAVE

Create data block eg. COURSE_BLOCK
Add text item eg COURSE_NAME, COURSE_TIME, ROOM

* Pada data_block i.e COURSE_BLOCK x perlu isi 'Query Data Source Type' dan 'Query Data Source Name' sbb bukannya nak display data. Ini untuk input data dan save ke dalam database. Jika tidak button 'SAVE' takkan berfungsi.

Trigger untuk button 'SAVE'

begin
if :course_block.course_name is not null then
   insert into course (course_name, course_time, room)
   values (:course_block.course_name, :course_block.course_time, :course_block.room);
   message ('1 RECORD WAS INSERTED');
else
   message ('You need to specify a valid course name');
end if;
exception
   when dup_val_on_index then
   message ('A course with this name already exists.');
end;

* tambah 'commit;'

begin
if :course_block.course_name is not null then
   insert into course (course_name, course_time, room)
   values (:course_block.course_name, :course_block.course_time, :course_block.room);
   message ('1 RECORD WAS INSERTED');
   commit;
else
   message ('You need to specify a valid course name');
end if;
exception
   when dup_val_on_index then
   message ('A course with this name already exists.');
end;

Thursday, September 20, 2012

Trigger for Button ( NEW, SAVE, FIND, CLEAR, EXIT )


To use Trigger:

Right click item > PL/SQL Editor
Select (User-named) > OK

*(User-named) - eg. for button NEW... right click button NEW > Property Palette , then change name from 'PUSH_BUTTON7' to 'BTN_NEW' . Then only Right click item > PL/SQL Editor > Select (User-named) > OK



Trigger for New and Clear Buttons

:course_block.course_name:=''; --assigne the null value to the course_name item on the course_block
:course_block.course_time:='';
:course_block.room:='';

Trigger for Save Button

begin
if :course_block.course_name is not null then
   insert into course (course_name, course_time, room)
   values (:course_block.course_name, :course_block.course_time, :course_block.room);
   message ('1 RECORD WAS INSERTED');
else
   message ('You need to specify a valid course name');
end if;
exception
   when dup_val_on_index then
   message ('A course with this name already exists.');
end;

Trigger for Save Button (Save, Commit, Clear)


begin
if :course_block.course_name is not null then
   insert into course (course_name, course_time, room)
   values (:course_block.course_name, :course_block.course_time, :course_block.room);
   :course_block.course_name:=''; --assigne the null value to the course_name item on the course_block
   :course_block.course_time:='';
   :course_block.room:='';
   message ('1 RECORD WAS INSERTED');
   commit;
else
   message ('You need to specify a valid course name');
end if;
exception
   when dup_val_on_index then
   message ('A course with this name already exists.');
end;


Trigger for Find Button

declare
   a course.course_name%type;
begin
   a:=:course_block.course_name;
   if a is not null then
      select course_name, course_time, room into :course_block.course_name, :course_block.course_time, :course_block.room
      from course where course.course_name=a;
   else
      message ('You need to specify a course name to be able to search courses');
   end if;
   exception
      when no_data_found then
      message ('A course with this name does not exist.');
      :course_block.course_name:='';
      :course_block.course_time:='';
      :course_block.room:='';
end;

Trigger for Exit Button

exit_form();

Add Data Block Manually (Add Text Item to Display Data) Without Using Wizard

Add Data Block Manually (Add Text Item to Display Data) Without Using Wizard

Object Navigator > Select Data Blocks > Click '+' symbol
Build a new data block manually
Click OK

Block automatically created/named (eg. BLOCK51)
Rename Block51 to STUDENT or STUDENT_BLOCK (or whatever name) 
Double click BLOCK51 for property palette or right click BLOCK51 > Property Palette
Under Database category, find 'Query Data Source Name' and enter STUDENT (must be required table name)
Under Database category, find 'Query Data Source Column' and enter column names required (STUDENT_ID, STUDENT_NAME, AGE)
      *type, length, precision, scale based on database
      *Tick Mandatory if data is NOT NULL (set to NOT NULL in database)
Click OK

Add Text Item
From Tool Palette, select Text Item to create in canvas (eg TEXT_ITEM53)
Right click text_item53 box > Property Palette
Find 'Name' and rename to STUDENT_ID (must be the column name to display)
Find 'Prompt' and enter Student ID (for text item label)
Repeat Add Text Item steps for STUDENT_NAME and AGE

Compile (Ctrl+T) and Run Form (Ctrl+R) for test.



Wednesday, September 19, 2012

Add Text Item Manually From Tool Palette to Canvas (without using data block wizard)

Biasanya add text item secara auto dari Data Block wizard. Kalau nak add secara manual, pada Tool Palette pilih Text Item dan klik pada canvas. 1 kotak text item akan dibina tanpa label. Untuk add label pada kotak text item itu, right klik pada kotak text item > Property Pallete. Cari ruangan Prompt dan taip label bagi text item itu seperti contoh rajah di atas.

Tuesday, September 18, 2012

FRM-30188: No initial value given, and other values are not allowed (item STUDENT.GRADE_LEVEL).



Cth:
Bila set item type as Radio Group, then add radio button, bila run form keluar error No initial value give, ...
Radio button: (bg Radio Group GRADE_LEVEL)
Junior – label Junior, Radio Button Value JR
Senior – label Senior, Radio Button Value SR
Graduate – label Graduate, Radio Button Value GR

Solution 1:
Tidak mendatangkan problem. Ini terjadi keranabila run form (sebelum execute query), by default kedudukan radio button tidak ditetapkan. Ini boleh diatasi dengan double klik pada GRADE_LEVEL (refer pada object navigator parent kepada radio button yang terlibat) dan set initial value pada JR (megikut contoh di atas).
So bila run form, by default, sebelum execute query (sebelum retrieve data), posisi radio button adalah pada label Junior.

Solution 2:
Boleh tambah lagi satu radio button label None dan biarkan Radio Button Value tanpa ada value. By default GRADE_LEVEL (refer pada object navigator parent kepada radio button yang terlibat) initial valuenya adalah tanpa value.
So bila run form, by default, sebelum execute query (sebelum retrieve data), posisi radio button adalah pada label None.

Tuesday, September 11, 2012

FireFox, IE crash with Forms 10g, Replace Jinitiator with JRE

From Oracle Forms, after start OC4J Instance, click Run Form icon.
This will open browser (chrome or i.e or firefox depend on default browser)

Fig: crash browser

url: http://vip-pc:8889/forms/frmservlet
error: No plug-in available to display this content.

Solution: 
Resource: http://www.exploreoracle.com/2011/01/06/firefox-ie-crash-with-forms-10g-replace-jinitiator-with-jre/

Open formsweb.cfg i.e E:\DevSuiteHome_1\forms\server\formsweb.cfg
Replace 2 lines as below.

change from

# System parameter: default base HTML file
baseHTML=base.htm
# System parameter: base HTML file for use with JInitiator client
baseHTMLjinitiator=basejini.htm
# System parameter: base HTML file for use with Sun’s Java Plug-In
baseHTMLjpi=basejpi.htm
change to
Make changes as shown in bold face below.
# System parameter: default base HTML file
baseHTML=basejpi.htm
# System parameter: base HTML file for use with JInitiator client
baseHTMLjinitiator=basejpi.htm
# System parameter: base HTML file for use with Sun’s Java Plug-In
baseHTMLjpi=basejpi.htm

***ORIGINAL ARTICLE
FireFox, IE crash with Forms 10g, Replace Jinitiator with JRE
Oracle Jinitiator is no longer compatible with oracle forms services. By default, Oracle Forms services 10g uses Jinitiator 1.3.1.22 to run Forms applications. Jinitiator was compatible with Internet Explorer 6 and Firefox version 2.0. But latest internet explorer like IE 8 and 9 crash with Jinitiator. Similar behavior is seen with Firfox version 3.0 and later.

To resolve this problem, you must configure JRE to work with forms services 10g. It is really easy and requires only very little work. Forms services 10g are by default configured to run with JRE 1.4.2_06. To get this working, locate following lines in your FORMSWEB.CFG file,

# System parameter: default base HTML file
baseHTML=base.htm
# System parameter: base HTML file for use with JInitiator client
baseHTMLjinitiator=basejini.htm
# System parameter: base HTML file for use with Sun’s Java Plug-In
baseHTMLjpi=basejpi.htm

Make changes as shown in bold face below.

# System parameter: default base HTML file
baseHTML=basejpi.htm
# System parameter: base HTML file for use with JInitiator client
baseHTMLjinitiator=basejpi.htm
# System parameter: base HTML file for use with Sun’s Java Plug-In
baseHTMLjpi=basejpi.htm

Make sue that following parmaments in FORMSWEB.CFG are as mentioned below.

jpi_download_page=http://java.sun.com/products/archive/j2se/1.4.2_06/index.html
jpi_classid=clsid:CAFEEFAC-0014-0002-0006-ABCDEFFEDCBA
jpi_codebase=http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,06
jpi_mimetype=application/x-java-applet;jpi-version=1.4.2_06

Now install J2RE version 1.4.2_06  from following URL,

http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase14-419411.html#j2re-1.4.2_06-oth-JPR



OR

you can also omit version no from following line,

jpi_mimetype=application/x-java-applet;jpi-version=1.4.2_06

after ommiting version, above line will look like following

jpi_mimetype=application/x-java-applet

Now you can use any latest JRE version. (Thanks to S Shamji  and JoeAStudent for thier comments related to version change )

Remove Jinitiator from you computer and restart OC4J instance. Now your Forms application 10g will use Sun’s Java plug-in instead of Jinitiator.

Update:

Looks like Firefox 12 does not work by omitting version no from formsweb.cfg. Instead you need to provide correct installed version.

For example, If you have jre 1.6.x installed in your system then edit following line as under.

jpi_mimetype=application/x-java-applet;jpi-version=1.6

The above line covers JRE 6 with all update levels.

If still facing problem then provide the exact version of  JRE with update level as under.

jpi_mimetype=application/x-java-applet;jpi-version=1.6.0_24

In “formsweb.cfg”,  jpi_classid indicates the version of JRE. “clsid:CAFEEFAC-0014-0002-0006-ABCDEFFEDCBA” indicates that 1.4.2_06 or any later version can be used.