Hire me on UpWork

Wednesday, April 11, 2012

How to Spell Check in Oracle Forms 6i ?

How will you feel if you able to check spelling in oracle forms?

Yea! Surely great…
Let’s try how we can do that.
This code uses the Microsoft Office spell checker, so you have installed Microsoft office suite. Now, create a procedure in forms under program units with the following code.

PROCEDURE spell_check (item_name IN VARCHAR2)
IS
   my_application   ole2.obj_type;
   my_documents     ole2.obj_type;
   my_document      ole2.obj_type;
   my_selection     ole2.obj_type;
   get_spell        ole2.obj_type;
   my_spell         ole2.obj_type;
   args             ole2.list_type;
   spell_checked    VARCHAR2 (4000);
   orig_text        VARCHAR2 (4000);
BEGIN
   orig_text := NAME_IN (item_name);
   my_application := ole2.create_obj ('WORD.APPLICATION');
   ole2.set_property (my_application, 'VISIBLE', FALSE);
   my_documents := ole2.get_obj_property (my_application, 'DOCUMENTS');
   my_document := ole2.invoke_obj (my_documents, 'ADD');
   my_selection := ole2.get_obj_property (my_application, 'SELECTION');
   ole2.set_property (my_selection, 'TEXT', orig_text);
   get_spell :=ole2.get_obj_property (my_application, 'ACTIVEDOCUMENT');
   ole2.invoke (get_spell, 'CHECKSPELLING');
   ole2.invoke (my_selection, 'WholeStory');
   ole2.invoke (my_selection, 'Copy');
   spell_checked := ole2.get_char_property (my_selection, 'TEXT');
   spell_checked :=SUBSTR (REPLACE (spell_checked, CHR (13), CHR (10)),1,LENGTH (spell_checked));
   COPY (spell_checked, item_name);
   args := ole2.create_arglist;
   ole2.add_arg (args, 0);
   ole2.invoke (my_document, 'CLOSE', args);
   ole2.destroy_arglist (args);
   ole2.RELEASE_OBJ (my_selection);
   ole2.RELEASE_OBJ (get_spell);
   ole2.RELEASE_OBJ (my_document);
   ole2.RELEASE_OBJ (my_documents);
   ole2.invoke (my_application, 'QUIT');
   ole2.RELEASE_OBJ (my_application);
END;

Now call the procedure in a Button passing the column name. Like
spell_check(‘Block_Name.Item_Name’);

Now all is yours…  :)

Say thanks, if it helps.

Monday, March 26, 2012

How to Dynamically Populate a Pop List ?

People want to know, how they dynamically populate a pop list? Means, At run time pop list will be populate. So there is no hard coded list element. Don't want to wait ?

You are at right place to learn it.

For this example code, i used SCOTT schema and DEPT table. You have to select privilege on the table.

It's a simplest example, First create a non-database block named DUMMY. create an item with type List Item named TXT_LIST. Data type CHAR, Length 30.
Now create a When-New-Form-Instance trigger at form/block level and write down the following code,

DECLARE
    group_id RecordGroup;
    group_name varchar2(10) :='abc';
    status NUMBER;
BEGIN
    group_id := find_group(group_name);
    if not id_null(group_id) then
        delete_group(group_id);
    end if;
   
    group_id := Create_Group_From_Query(group_name,'select DNAME,TO_CHAR(DEPTNO) from DEPT');
/* Select statement must have two column*/
    status := Populate_Group(group_id);
    Populate_List('DUMMY.TXT_LIST',group_id);
END;


Hope it works...

Monday, March 5, 2012

How to check, if it is first record of the block ?

At multiple-record block, you are looking for the record number, where the cursor is. Say, your at record no 5 and you want to know u'r in five. To get this follow the bellow code...

record_no:=GET_BLOCK_PROPERTY('block_name',CURRENT_RECORD);
 
Hope this helps...