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 ?

Similar Messages

  • 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

  • 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 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

  • 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.

  • 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

  • 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

  • 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 -

  • 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

  • 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.

  • 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

  • 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

  • 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

  • OM base table columns

    What is the diff betn these columns in OM base tables?
    sold from org id
    sold to org id
    ship fom org id
    ship to org id
    invoice to org id
    Thx!!

    sold from org id --> This is organization from which you are selling and it'll be map to your organization_id
    sold to org id ---> This is cust_account_id and will map to HZ Tables
    ship fom org id ---> This is the organization froum which you actually ship goods and again coming from your organization_id from hr_all_organization_units
    ship to org id ---> This is the site_use_id in again HZ Tables and ship to id of customer where you send your goods
    invoice to org id---> This is the site_use_id in again HZ Tables and bill to id of customer where you send invoice for your goods
    Understand the LInkage b/n below major tables on HZ
    hz_parties
    hz_cust_accounts
    hz_cust_acct_sites_all
    hz_party_sites
    hz_cust_site_uses_all
    hz_locations

  • Selection criteria based on non-primary key columns in Custom-SQL

    Hi all,
    Could anybody please tell me how to perform a search using non-primary key columns, The query is written in Workbench under Custom Sql --> Read Object. The Query goes something like this
    select * from Employee where firstName like #name
    where firstName is a Non-primary key column.
    The Java Code goes like this
    Employee empm = new Employee();
    empm.setFirstName("John");
    Employee employees = (Employee) session.readObject(empm);
    This does not fetch me any values . I dont want the queries to be written in any java class. Is there Any other way to do it ??

    Hi all,
    Could anybody please tell me how to perform a
    search using non-primary key columns, The query is
    written in Workbench under Custom Sql --> Read
    Object. The Query goes something like this
    select * from Employee where firstName like #name
    where firstName is a Non-primary key column.
    The Java Code goes like this
    Employee empm = new Employee();
    empm.setFirstName("John");
    Employee employees = (Employee)
    session.readObject(empm);
    This does not fetch me any values . I dont want the
    queries to be written in any java class. Is there Any
    other way to do it ??I dont think you have set it up the right way to do what you want to do. You need to click on "Queries" on the Employee Descriptor and then Named Queries and then give a name for a named query and then choose ReadObjectQuery under type and then choose SQL under Format. Enter the custom SQL and then export the project xml file.
    Then in your application logic you have to call this named query the usual way.
    Employee employee = (Employee)session.executeQuery("findEmployeeByName,Employee.class,args);
    where args is a vector containing the name of the Employee.

Maybe you are looking for