Thursday, 1 December 2011

Querying on a non database field in Oracle Forms

Here is small piece of code for Querying on a non database field in the Custom Oracle Form.

Steps to be followed :


1.  Sample Block :  XXSS_BLK
               prd_name    -   Non database, read only field.
               prd_id         -   Database, hidden field
               start_date    -   Database field
               end_date     -   Database field.



2. Add a Pre-Query trigger on the block , where it contains a non database fields for querying.

3. Sample code for the Pre - Query trigger :

    l_where       VARCHAR2(250) := 'Where 1 = 1';

BEGIN
           l_where :=  l_where || 'AND prd_id IN (SELECT product_id FROM product '
|| ' WHERE product_name like '''||'%'||:XXSS_BLK.PRD_NAME||'%'')';


SET_BLOCK_PROPERTY('BLOCK_NAME',DEFAULT_WHERE,l_where);

END;

These steps should allow querying on the non database fields in the Custom Oracle form.

The same can be modified according to the requirements.

Hope this helps.

3 comments:

  1. Thanks Naren..good stuff on non database field in oracle form..i tried it once and it worked like charms..thanks to u :)

    Keep Writing and posting such things....

    Renu

    ReplyDelete
  2. Thanks renu for your comments

    ReplyDelete
  3. Hi Naren,
    I have a master detail block and all the code to retrieve the record is based on a button.
    User enters a date and clicks on 'show records' then all the records are displayed. Now in the detail block i would like to query on a non db item. I followed your steps. it works but it gives more records. basically it is bypassing the 'show records' functionality.
    please help
    megha

    ReplyDelete