Sorting by non-base table fields - Is it possible?

I have a form with a block that associated with a table.
There are several base table fields and several non-base table fields displaying information in this block.
I need to sort the data in this block by non-base table fields.
Is this possible without rewriting the form so that the block is not associated with a base table, and then manually populating the block?

This may help you.
Example
I have a customer_id in my base table, but I want the data ordered by customer_name which is from another table.
Answer
You need to create a function in the database with an associated
pragma to specify the level of purity of the function
WNDS (write no database state)
WNPS (write no package state)
PRAGMA RESTRICT_REFERENCES(fn_get_dname, WNDS, WNPS);
Function fn_get_dname (p_empno in number) return varchar2 is
v_dept_name varchar2(40);
begin
select dname into v_dept_name
from dept, emp
where dept.deptno = emp.deptno
and emp.emp_no = p_emp_no;
return v_dept_name;
end;
order by in a block based on the emp table (assuming you want a list of employees by department name)
order by fn_get_dname(empno), empno

Similar Messages

  • Sorting by non-base table fields in Oracle Forms

    I have a form with a block that associated with a table.
    There are several base table fields and several non-base table fields displaying information in this block.
    I need to sort the data in this block by non-base table fields.
    Is this possible without rewriting the form so that the block is not associated with a base table, and then manually populating the block?

    Hi mark
    You could do the following
    Create a database function on the server,
    The function should return the value that you want to order by.
    In your form update the ORDER BY clause to use the function
    Example:
    Assume you have a block base on the employee table,
    and you want to order by the department name not the department no (The employee table only contains the department no)
    The function will be
    CREATE OR REPLACE FUNCTION "TEST_ORDER" (pDEPT_NO NUMBER) RETURN VARCHAR2 AS
    DptName VARCHAR2(100);
    BEGIN
    SELECT DEPT_NAME
    INTO DptName
    FROM DEPT
    WHERE DEPT_NO = pDEPT_NO;
    RETURN DptName;
    END;
    The form block ORDER BY Clause will be
    TEST_ORDER(DEPT_NO)
    Hope this will solve your problem
    Regards

  • Order by on a non-base table field

    I want to order by on a non-base table field in a form. Can any body help how to do this in a form.
    Thanks

    Ramesh,
    I am not sure of ver 4.5. But in v6i, I did something similar.
    What I did was :-
    1. Based the Block's datasource on a stored procedure and
    not TABLE
    I'm not sure if it can be achieved in 4.5. First check if the block data source can be based on a stored procedure.
    Here's a sample code of what i did :-
    /* Description : Using a stored procedure as a block datasource.
    Author : Shailender Mehta
    Create Or Replace PACKAGE my_datasource Is
    /* Shailender Mehta */
    TYPE outrec is RECORD (comp_id tbgp_gl_detail.comp_id%Type
    ,cc_id tbgp_gl_detail.cc_id%Type
    ,journal_no tbgp_gl_detail.journal_no%Type
    ,account_code tbgp_gl_detail.account_code%Type
    ,debit_amt tbgp_gl_detail.debit_amt%Type
    ,credit_amt tbgp_gl_detail.credit_amt%Type
    ,sort_order Number(1)
    TYPE outcur is REF CURSOR RETURN outrec;
    PROCEDURE outquery (resultset In Out outcur
    ,p_journalno In Number);
    END;
    Create Or Replace PACKAGE BODY my_datasource IS
    PROCEDURE outquery(resultset In Out outcur
    ,p_journalno In Number)
    Is
    BEGIN
    OPEN resultset FOR
    SELECT comp_id
    , cc_id
    , journal_no
    , account_code
    , debit_amt
    , credit_amt
    , Decode(substr(account_code,6,1), 'g', 1,
    'd', 2,
    'b', 3,
    'h', 4,
    'f', 5,
    'a', 6,
    'c', 7, 8) sort_order
    FROM tbgp_gl_detail
    WHERE journal_no = p_journalno
    ORDER BY 7;
    END;
    END;
    Use the Block Data Wizard, which will guide you step by step what next to be done.
    In my example, I'm sorting the resultset by the 6th character of the string Account Code.
    In your case, you could join the main table by the one used in your POST-Query in the stored procedure and sort the resultset.
    - Shailender -

  • Calculated non-base table field in a tabular form

    I am struggling with creating a non-base table calculated field in a tabular form in ApEx 3.1
    Can you point me in the right direction
    I thought this would be fairly easy to do, but I cant work out how to do it
    Requirements
    1) Tabular Form based on a table with QTY and PRICE columns
    2) TOTAL is a non-base table field, based on QTY * PRICE
    3) If the Qty or Price changes, the TOTAL should be re-calculated
    Example
    QTY   PRICE  TOTAL
    ===    =====  =====
    3       5          15
    10      50         500
    20      3           60
    Environment
    ApEx 3.1, Oracle 10 and Oracle 11 databases
    I recommended to upgrade to a newer version of ApEx but the request was rejected so Im stuck with 3.1

    Thanks, but its not the solution that I am after
    I am looking for a solution that will ...
           1) not require the calculated value TOTAL to be stored in the table
    and 2) re-calculate the TOTAL when I modify the dependent values (QTY and PRICE) before I save the changes to the database
    I am still looking for a solution if anyone can help

  • Ordering a block by a non-base table field

    Hello,
    I have heard you can order your block by a
    non-base table field by using a stored function. Does anyone know how to do this?
    Lisa

    In a WHEN-VALIDATE-ITEM user have to press ENTER or TAB key too !!
    anyway he have to press something.
    KEY-NEXT-ITEM and KEY-PREVIOUS-ITEM is a good choice.
    You can create a timer who fire each second, verify that user enter something new in the field (by comparing old and new value), then do execute_query

  • Tabular form with non base table field

    I want to develop a tabular form with
    1. A non-base table edit field to accept a value
    2. Insert/update another table based on the input value
    3. Also, computed field on each row based on other fields on the records (like post-query trigger in oracle forms at block level - for each row)
    Thanks,
    Rachna

    Thanks for your reply.
    Varad, I like the link you sent me. It has a lot of good information.
    I created a process (under page processing) called "Update/Insert Process" that dosn't seem to be working.
    Question, I created a manual tabular form with SQL Query and created a process (under page processing) called "Update/Insert Process", then I check for each record in the tabular form. If the old value <> new value then I update/insert in the new table.
    Any step by step will be highly apprciated - to create process/validation etc.
    Thanks,
    Rachna

  • Can Shuttles be based non-base  table ViewObjects with transient attributes

    Hello,
    Users have to select records from a data collection and a Shuttle looks most appropriate/nice for this purpose. We can introduce technical intersection tables in order to generate the Shuttles with JHeadstart 10g R3 if necessary, but there is no “functional” need to update any data in the database and therefore it would be practical if the ‘right’ side from a Shuttle can be based non-base table ViewObjects with transient attributes only. So, our interested is to know which records have been selected, i.e. moved to the right side from the Shuttle.
    Hope that my question is clear enough.
    Greetings,
    Michael

    Michael,
    This cannot be generated out-of-the-box.
    It is easiest to add the shuttle post-generation to your page, and then create a custom template to generate your custom shuttle into the page. I suggest you take a look at an example of a generated shuttle in a page, and the JHeadstart IntersectionShuttleBean class. You will see that the value property of <af:selectManyShuttle> points to the selectedKeys method in the JHeadstart Shuttle bean. In your case, you can create your own managed bean and bind the value property to your own method which will provide you access to the selected rows. The value property of the selectItem within the af:selectManyShuttle determines the property that is used to identify the selected row (which is the row key in case of Jhs-generated shuttles).
    Steven Davelaar,
    JHeadstart Team.

  • Insert records into non base table

    Hi
    I would like to insert records into a table when a button is clicked. The table is a non base table. I am trying to save records displayed in a form into a history table which is not part of the form. I am using the following code stored in a program unit then called when the button is pressed. It doesn't generate any error but the records are not inserted. Can anyone please help.
    hist_id := 1;
    cust_name := :CUSTOMER.cust_name;
    loan_date := :LOAN.loan_date;
    return_date := LOAN.return_date;
    FORMS_DDL('INSERT INTO LOAN_HISTORY VALUES'||hist_id||','||cust_name||','||loan_date||','||return_date);

    Why do you need forms_ddl built in for a DML statement to be used in form?
    U can directly use insert.
    hist_id := 1;
    cust_name := :CUSTOMER.cust_name;
    loan_date := :LOAN.loan_date;
    return_date := LOAN.return_date;
    INSERT INTO LOAN_HISTORY VALUES (hist_id,cust_name,loan_date,return_date);
    It should work perfectly.

  • Two LVO link to the same not base table field

    I would like to know if it possible to relate two LOV to the same not base table field. If it possible, how to do it.
    Thanks,
    Julia

    You can set the LOV with set_item_property(<item>,LOV_NAME,<lov>). This way you can associate 2 or more different LOV's with an item. Of course only one LOV can be active at any given time.

  • Non-base tables

    What is non-base table when refered in forms ?
    null

    moorthy kathirava (guest) wrote:
    : What is non-base table when refered in forms ?
    When you create a Block/form without any base table, ie., Form
    containing controls which are not necessarily related to one
    table is called non base table block/form.
    Murugan
    null

  • Query on Non-base-table column in form

    Hi,
    Does anyone have an example of code to allow users to query on non-base-table column from forms? For example, a personnel form displays a persons' name and department name. The form is based on PERSON table, which contains the department id, not the name. The form uses post-query to display the department name. When in query mode, the user wants to enter department name, and display the people in the department (still using this form, which is based on PERSON table.
    Thanks!

    Try this:
    For data block person set these properties as follows:
    1.Set Query Data Source Name = "person , departments"
    2.Set DML data target name = "person"
    3.Set Where Clause to join i.e. condition "person.dno = departments.dno"
    For filed department name set these properties as follows:
    1.Data base item = "Yes"
    2.Column Name = "departments.dname"
    3.Query Only = "Yes"
    4.Insert Allowed = "No"
    5.Update Allowed= "No"
    6.Keyboard Navigable = "No"
    If you face ambiguous column name check for the same filed name exist on both tables and set column name for this filed to person.filed_name
    Regards
    null

  • Order by on Non-base table Item

    Hi,
    I have a base table block on Dept and some of the non-base table items(which are emp table and being populated through post-query).
    So, i have some base table items and non-base table items on the same block.
    No my problem is, i have to do ORDER BY on one of non-base table items..
    How can i do this ?
    Thanks in advance.

    The obvious answer is to create a view upon which to base the block, or alternatively you could use a FROM Clause Query so that you don't have to set the values in your POST-QUERY trigger.
    Richard

  • Want to sort the records based on non-base table item

    I have a multi-record block and I am trying to sort the data based on nbt item
    I have a table called X which has x_type,x_code fields.
    The table on which the block is created is Y. the table Y has x_type and y_desc as its fields
    form layout is like below .the x_type is key field on which I have to query the records
    and x_code is a non-base item in the form.I want to sort the records by X_code.
    x_code y_desc
    A     xyz
    c par
    B     lmn
    my pre-query has this code
    select x_type from y
    where
    x_type := x_type;
    post-query has this code
    select x_code from x
    where x_type = :x_type;     
    It works fine in Enter-Queryand execute query mode. but when I am sorting the records on
    nbt item x_code by SET-BLOCK-PROPERTY it doesn't do any thing

    Hi Tony ,
    I have created a function and in Pre-Query & have add this
    SET_BLOCK_PROPERTY('b1', ORDER_BY, 'fn_get_code(x_type)');
    and the function created is as below
    Function fn_get_code (p_x_type in varchar2) return varchar2 is
    v_code varchar2(40);
    begin
    select x_code into v_code
    from X, Y
    where X.x_type = Y.x_type
    and y.x_type = p_x_type
    return v_code;
    end;
    when I run the form and execute query it comes up with the error message
    FRM-40505 and when I pressed display error it shows
    SQL Statement error:
    SELECT ROWID,X_TYPE,X_CODE
    FROM Y order by fn_get_code(x_type)
    Error:
    "ORA-00904: "FN_GET_code": invalid identifier"
    Is it that I need to create a function on the database?. As I have created function
    in program unit section

  • Sorting based on non-base table columns

    I have a form block based on X table. There are also some columns from Y table in the same block and the tables X and Y are joined through the appropriate columns. I want to sort the queried record in the block ( based on table X ) based on two columns that are present in the Y table. How do I do this? Any help would be highly appreciated. Ofcourse! we can create a view and achieve that. But I don't want to create a view. Also I can use select statement in the order by column. But it works if I select one column. But when I select two columns it says too many value. Any solutions

    why dont u create a function
    and sort by the returning values ?

  • Assigning a Value to a Base Table BLock Field

    hi,
    I have a form in which a block is a base table block . i need to change the value of a field. currently it shows the value of a field from the Table on which the block is based . I need to change the value of that field to display some other value of another table.
    i have a written select statement like this
    select name into vname from ws_emp where ecode = 101
    then i have assigned to this base table field
    :bt_person.ti_v_name := vname;
    this i have created in the base table blocks Post query
    but it is not assigning value
    pls correct me and suggest me if there is any other better method to do this
    Sarav

    That SHOULD work in the Post-Query trigger of the block, but doing that is never a good idea. By replacing a base-table field with any value, it causes Forms automatic processing to lock the row immediately, so no other person running your form can call up the same data. And it causes Forms to think you need to update the record, so the record's status is changed to 'CHANGED' from 'QUERY'.
    It would be better to create a non-base-table field in the block, and put the name into that field.

Maybe you are looking for

  • Expanding text in an auto-sized popup window can cause the text to overflow

    First Topic includes a popup link. This includes rather long expanding text. When this is activated, the popup is too small to show everything, and has no scrolling possibility. Anyone know a workaround? I tried to report this as a bug through the Ad

  • EPM Error while creating a local connection

    Hello everyone, I am a Dashboards designer and am new to BPC 10 MS. I am working on a dashboard that connects to BPC 10 MS to retrieve data via the EPM Connector. For this a 'Local' connection type must be used when creating the report in the Excel s

  • Problem with 0Date

    Hi Experts, Data came to PSA, in PSA it is showing error as below. Value with 000 of charecteristic 0Date is not a number with space. In this I am not using 0Date. Char. Please help me. Thanks in Advance.

  • In windows how do we install and activite multiple versions of tuxedo at the same time ?

    Hi All, In windows how do we install and activate multiple versions of tuxedo at the same time ? Advance wishes

  • ESS + EA and PB form for Malasiya Issue

    Hi, In the ess when I am running the servies EA and PCB forms displaying the error. Variant SAP&P2 of program RPCTP2L0 is not the current version for PCB form. Variant SAP&P2 of program RPCTP2L0_L0 is not the current version for EA. I created new var