Validating Tabular Form Column Against Value From Another Table

Hi,
I am brand new to this forum, so please bear with me a little!  I only have a small amount of experience writing PL/SQL, and I've never written Javascript or JQuery before.  I am an Oracle DBA, and I have coding experience in C and PERL, so I do have a solid technical background.  But, I need some advice on the best way to approach a problem.
I have a database application in Oracle Apex (version 4.2) with a tabular form against a table: let's say Table #1 with cols 1A, 1B, and1C.  I need to ensure that the value entered into col B isn't greater than the value of a column in another table (let's say Table #2 col 2A).  Conceptually, the amount of money available is in Table #2, and the rows of my tabular form are an act of spending money (like orders or invoices), so I need to make sure we don't spend more than we have.  Does that make sense?
Does anyone have any advice for the best way to do this?  I'm figuring the biggest issue here might be that we have to account for people entering mutliple rows in the tabular form at one time, right?  So, if a person entered 3 orders/invoices, I need a total to make sure they didn't spend more than we have in Table #2.
I greatly appreciate your help! 
Best Regards,
Laurie Baublitz

Hi!
You need one process of type ajax callbacks like:
DECLARE
   l_limit nubmer;
   l_number1 number := apex_application.g_x02;
   l_returnValue VARCHAR2(200);
BEGIN
   select A2 into l_limit from table2;
   if l_number1 > l_limit then
      l_returnValue := 'LIMIT IS NOT SO BIG';
      if l_returnValue is not null then
         --this will write l_returnValue to the buffer, and the ajax callback will receive this
        htp.p(l_returnValue);
      end if;
  end if;
END;
Then you need one javascript on page, code is something like:
$('input[name=your column in tabular which is change]').live('change', function(){
   //if value of changed field differs from an empty string
   if($(this).val()!=''){
      //put target element in a var to reference it in the ajax success callback
      var num  = $('input[name=your column in tabular with value]');
      $.post('wwv_flow.show',
             {"p_request"      : "APPLICATION_PROCESS=your ajax callback function",
              "p_flow_id"      : $v('pFlowId'),
              "p_flow_step_id" : $v('pFlowStepId'),
              "p_instance"     : $v('pInstance'),
              "x01"            : $(this).val(),
              "x02"            : $(num).val()
              function(data){
                 if(data !=''){
                 alert(data);
I can not guarante that code is 100% working, if not you need to do some changes or make an example on apex.oracle.com and provide credentials here.
Regards,
drama9346

Similar Messages

  • How to make validation in Bean and select value from another table

    I want to know how to select data from table in backing bean according to primary key i have
    the problem is that
    i have a table Employee_Salary contains Employee ids and their salary
    Empoloyee_Salary table
         Employee_ID      Number
         Employee_salary Number
    And Another table Called Employees
    Employees table
         Employee_ID     Number
         IsManager Varchar2 its value is [*Yes or NO*]
    and other columns that i don't care about this table
    i have on a jsff page an <af:table> this table is editable this is the Empoloyee_Salary table
    *i want to check before save or after insert if this employee is Manager [from Employees tabke(yes or no)] the salary*
    cannot be less that 100
    i want to know how to make this how to select the value from employees table according to the id i have in the employee_salary table how to make this and make this validation
    i have to select IsManager from Employees Table to see if this manager or no
    i want to know how to make this in a bean
    i use jdeveloper 11g
    and my project is ADF Fusion project
    and the page that have the Emplpyee_Salary table is JSFF
    thanks in advance

    You might want to write this code in a validator on the entity object if it should apply from every screen.
    If you want to access view objects from a backing bean the basics are here: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcservices.htm#sthref918

  • Default value from another table in dummy field on a portal form ..

    A form based on a table :
    id
    name
    xx_id
    I created a dummyfield on the form in which i would like the
    name corresponding to xx_id -> I would like to fetch a value
    from another tabel into a dummy field.
    thanx
    Trine Hindsholm

    I could do this task by creating the form manually - is there anyway I can modify the insert for a form created by the wizard?

  • Default value from another table - sql query

    I'm trying to make the default value of a text item as the result from an sql or pl/sql statement. I keep getting errors when I try to use a pl/sql statement to do this. Has anyone else done this?

    OK, here is what I tried to put in. I have a form and I wanted to add a text field that is derived from another table, such as:
    select question from qa_main where seq=:quest_num
    So, what I want is to have a form where questions on tests are answered, and I want the text of the question to be brought over from the question table. I'm not sure if I'm using the correct syntax, but the ":quest_num" would be a reference to a question number in the answer table that is linked to the sequence number (primary key) in the questions table.
    Of course if there are better ideas, please let me know. :)

  • Dynamic Column Names from one table and its corresponding values from another table

    I have 2 tables. First tables gives the specification if a column is required or not. we have the 2nd table with the same column name where we provide the actual values.
    I want to select all the required columns from the 1st table and retrieve the values for those from the 2nd table. Both this i want to achieve in a single select statement.

    This wil require a dynamic Query with a Pivot
    DECLARE @ColsPivot as VARCHAR(MAX);
    DECLARE @Query  AS VARCHAR(MAX);
    1. Retreive the ID for all required field
    SET @ColsPivot = (SELECT STUFF((SELECT  ',' + quotename(CAST([RequirementID] as varchar(3))) FROM [dbo].[Requirement] WHERE required=1 FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)') ,1,1,''));
    This will give you : [1],[2],[3],[8],[9],[14] for exemple.
    2. Build your Query
    SET @Query ='SELECT ClientID,'+@ColsPivot+''
        FROM (
            SELECT [ClientID],[RequirementID],[Value]
            FROM dbo.RequirementValue
            WHERE ClientID=@CliendID --Optional SP parameter
        )src
              PIVOT(
                MAX(Value)
                for [RequirementID] in ('+@ColsPivot+')
        ) p';
    3. Exec(@Query);

  • Ain't getting it: insert into table by determing value from another table

    I have a table (PERCENTILE_CHART) with percentiles and test scores for different tests:
    Structure:
    Percentile, Reading_Test, Writing_Test
    Data:
    30,400,520
    31,450,560
    97,630,750
    98,630,780
    99,640,800
    The data is currently in ascending order by Percentile.
    If a person took the Reading test and scored 630 he or she would be in the 98th (not 97th) percentile of the class taking that test.
    I wrote a statement to return the percentile:
    select Percentile
    from ( select ROWNUM, PERCENTILE
    from PERCENTILE_CHART
    where READING_TEST <= '650'
    order by READING_TEST desc)
    where ROWNUM < 2 order by PERCENTILE desc;
    This select works and is able to determine the highest percentile for a score.
    Ok, now I want to process all the records in a STUDENT table which have
    test scores and insert them in a new table along with the percents, normalizing the data in the process.
    Have this:
    STUDENT:
    Student_Name,Student_ID,
    John Smith,121,Reading,98,Writing,90
    Maggie Smithe,122,Reading,95,Writing,96
    And needs to be moved to into SCORES with the percentiles, so I get this:
    SCORES:
    Student_Name,Student_ID,Test_Name,Percentile
    121,Reading,98
    121,Writing,90
    122,Reading,95
    122,Writing,96
    This is were I get confused. How do I insert the data into the SCORES table with the percentile? I think calling a function in package is the way to do it:
    function oua_Test_Percentile_f (
    p_Test_Name in char,
    p_Test_Value in char)
    return char as
    -- Declare variables
    c_Return_PTile char(2);
    begin
    select PERCENTILE into c_Return_PTile
    from (select ROWNUM, PERCENTILE
    from PERCENTILE_CHART
    where p_Test_Name <= '&p_Value'
    order by p_Test_Nmae desc)
    where ROWNUM < 2 order by PERCENTILE desc;
    return c_Return_PTile;
    end;
    But this function doesn't return the percentile even though it is based on my working select mentioned earlier. It returns a blank for all tests.
    And even if it is working how do I then populate the SCORES table?

    You may want to use analytical functions so that you can determine the percentile across all of the different scores:
    SQL> with
    2 PERCENTILE_CHART as
    3 (
    4 select 30 PERCENTILE, 400 READING_TEST, 520 WRITING_TEST from dual union all
    5 select 31 PERCENTILE, 450 READING_TEST, 560 WRITING_TEST from dual union all
    6 select 97 PERCENTILE, 630 READING_TEST, 750 WRITING_TEST from dual union all
    7 select 98 PERCENTILE, 630 READING_TEST, 780 WRITING_TEST from dual union all
    8 select 99 PERCENTILE, 640 READING_TEST, 800 WRITING_TEST from dual
    9 )
    10 select
    11 max(percentile) over (partition by reading_test) HIGHEST_READING,
    12 max(percentile) over (partition by writing_test) HIGHEST_WRITING,
    13 percentile_chart.*
    14 from
    15 percentile_chart
    16 /
    HIGHEST_READING HIGHEST_WRITING PERCENTILE READING_TEST WRITING_TEST
    30 30 30 400 520
    31 31 31 450 560
    98 97 97 630 750
    98 98 98 630 780
    99 99 99 640 800
    SQL>
    I wasn't exactly sure how you wantd to coorelate this to the student records though; the student table had only two column name headings but there were four rows listed as examples and had fewer rows than in the percentile_chart table...
    If you join the student table to the able query it might be what you are looking for.
    You can create another table based on the output of your query by doing:
    create table scores
    as select * from
    (insert your query here)
    /

  • How to update this table with values from another table ?

    Hi
    I have a table "regies". I want to replace the values of the column "regies.agent" by the value of the column "regies_personnes.id"
    As you see the tables have a common values column. ie regies.agent = regies_personnes.nom
    Table "regies" :
    Insert into "regies" (AGENT) values ('Humberdot Alain');
    Insert into "regies" (AGENT) values ('Danard Patrick');
    Table "regies_personnes" :
    Insert into REGIES_PERSONNES (NOM,ID) values ('Humberdot Alain',1);
    Insert into REGIES_PERSONNES (NOM,ID) values ('Danard Patrick',2);
    Before we have this
    sql>select agent from regies ;
    Humberdot Alain
    Danard Patrick
    After the update, the result should be
    sql>select agent from regies ;
    1
    2
    Thank you for your kind answer.

    You will face error if you have duplicates
    ORA-01427 Single row subquery returns Multiple rows.Try this way
    create table regies(agent varchar2(30));
    create table regies_personnes( nom varchar2(30),id number);
    Insert into regies (AGENT) values ('Humberdot Alain');
    Insert into regies (AGENT) values ('Danard Patrick');
    Insert into REGIES_PERSONNES (NOM,ID) values ('Humberdot Alain',1);
    Insert into REGIES_PERSONNES (NOM,ID) values ('Danard Patrick',2);
    Insert into regies (AGENT) values ('Humberdot Alain');
    Insert into regies (AGENT) values ('Danard Patrick');
    Insert into REGIES_PERSONNES (NOM,ID) values ('Humberdot Alain',1);
    Insert into REGIES_PERSONNES (NOM,ID) values ('Danard Patrick',2);
    commit;
    update regies r set agent = (select id from regies_personnes p where r.agent = p.nom
    and rownum=1)
      where exists (select id from regies_personnes p where r.agent = p.nom
    commit

  • Id from one table showing value from another

    I have an article id (rs_comments.id_com) but I would like it
    to take this data and collect the value from another table.
    I have joined the two tables with:
    SELECT * FROM blg_comment_com INNER JOIN blg_article ON
    idart_com=id_art
    WHERE valid_com=1
    ORDER BY date_com DESC
    rs_comments.idart_com needs to be equal to rs_comments.id_art
    displaying the value from rs_comments.title_art
    How would I go about doing this. There only seems to be an
    option in DW to do this with a dynamic list/menu but I just want to
    display the text without option to change it.
    Any help much appreciated.

    i was stupid. The answer was staring me in the face. No
    wonder no-one bothered to reply...

  • Breakout table (fill table with matching data from another table)

    Hi
    I've been trying to study old discussions about breakout tables. I feel I'm close, but still no cigar :-)
    In plain english, I'm trying to autocreate rows with data on a table, based on matching values from another table. E.g. have a table to display all rows where type = AssetX
    I have attached a screenshot of my "master table" called Assets:
    I'm looking to prefill Asset name, Total from this table and populate a new table called e.g. Greenhouse
    Where I'd be adding more data (date, income, expense).
    Any help whould be greatly appreciated.
    Thanks!

    Hi,
    Here is a Sample Query.
    Update Emp A
    Set Sal = (Select Sal from emp b where
    a.empno = b.empno)
    where empno in (select empno from emp);
    Regards,
    Ganesh R
    null

  • Tabular form condition type value of item / column in expression 1

    Hi
    Question 1
    I was wondering if anyone can help with the necessary syntax so that I can set a Condition Type for a column in a Tabular Form.
    What I'm trying to do is show or hide a column based on the contents of another column in the same row for instance show column DETAIL or DETAIL_READ_ONLY if column READ_ONLY is set to 'Y'
    Value of item / column in expression 1 = #READ_ONLY# or READ_ONLY (alas neither works)
    Expression 2 = Y
    I can set all the DETAIL or DETAIL_READ_ONLY columns to either hide or show at the same time by
    Value of item / column in expression 1 = P100_READ_ONLY (works well but lacks granularity)
    Expression 2 = Y
    Question 2
    Are Tabular Forms such that all fuctionality has to be global, what effects one column must be the same for all
    I know that Oracle prefers that developers don't use tabular forms but they are usefull for data visability when setting up related data in the same table.
    e.g. surveys, questionnaires etc apps the web was made for
    Thanks
    Derek

    Hi Sandro
    Thanks for replying
    The problem I have is Tabular Forms
    Detail Text Detail Read Only Read only
    Event 1a Event 1b Y
    Event 2a Event 2b N
    Event 3a Event 3b Y
    What I want it to look like is
    Detail Text Detail Read Only Read only
    ___________Event 1b__________ Y
    Event 2a_____________________ N
    ___________Event 3b__________ Y
    This would mean that the Text Field containing Event 2 could be updated but the Display Only fields containing Event 1 and Event 3 cannot be changed.
    The trick is to be able to mix and match data types for the same data because Tabular Forms columns don't have a conditional read only choice.
    Sorry about the rudimentary diagram, but its the old 80 / 20 rule =>20 percent functional
    Edited by: derekf on 4/02/2013 17:50

  • Changing tabular form column to checkbox

    I have a tabular form in 3.2. There is a column that is a text field, but really should be a checkbox. I have tried changing the region source to something like, select a, b, APEX_ITEM.CHECKBOX(3, PRIMARY FLAG) "PRIMARY_FLAG", d
    from my_table
    WHERE a = :P52_XPROD, but the column still shows up as a text field, displaying a value like "<input type="checkbox" name="...etc.
    Is it possible to change a tabular form column to a checkbox in 3.2?

    edit your report attributes, then edit your column and change "display as" to "standard report column"
    Thanks
    Tauceef

  • FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.

    Hi,
    I have one multi record block in which i want to fetch values
    (more then one record) from another table using select statement
    IN KEY NEXT ITEM.I am getting following error.
    ORA-01422: exact fetch returns more than requested number of rows
    Thanks in advance.

    In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
    Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
    However, you can replace the explicit cursor with implicit one like
    go_block('non_db_block_name');
    first_record();
    FOR v_tab IN (SELECT *
    FROM tab
    WHERE col_name = :variable)
    LOOP
    :non_db_block_name.field1 := v_tab.col1;
    :non_db_block_name.field2 := v_tab.col2;
    next_record();
    END LOOP;

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to create a new row for a VO based on values from another VO?

    Hi, experts.
    in jdev 11.1.2.3,
    How to create a new row for VO1 based on values from another VO2 in the same page?
    and in my use case it's preferable to do this from the UI rather than from business logic layer(EO).
    Also I have read Frank Nimphius' following blog,but in his example the source VO and the destination VO are the same.
    How-to declaratively create new table rows based on existing row content (20-NOV-2008)
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/13-create-with-params-169140.pdf
    I have tried:
    1.VO1(id,amount,remark1) and VO2(id,amount,remark2) are based on different EO,but render in same page,
    2.Drag and drop a Createwithparams button for VO1(id,amount,remark),
    3.add: Create insertinside Createwithparams->Nameddata(amount),
    4.set NDName:amount, NDValue:#{bindings.VO2.children.Amount}, NDtype:oracle.jbo.domain.Number.
    On running,when press button Createwithparams, cannot create a new row for VO1, and get error msg:
    <Utils> <buildFacesMessage> ADF: Adding the following JSF error message: For input string: "Amount"
    java.lang.NumberFormatException: For input string: "Amount"
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    Can anyone give some suggestions?
    Thanks in advance.
    bao
    Edited by: user6715237 on 2013-4-19 下午9:29

    Hi,CM,
    I'm really very appreciated for your quick reply! You know, today is Saturday, it's not a day for everyone at work.
    My principal requirement is as follows:
    1.select/check some rows from VO2, and for each selection create a new row with some attributes from VO2 as default values for VO1's corresponding attributes, and during this process the user may be cancel/uncheck or redo some of the selections.
    --so it's better to implement it in UI rather than in EO.
    2.it's better to implement this function with declarative way as in Frank Nimphius' blog.
    --little Jave/JS coding, the better. I only have experience in ORACLE FORMS, little experience in JAVA/JS.
    In order to get full information for the requirements of my use case, can take a check at:
    How to set default value for a VO query bind variable in a jspx page?
    (the end half of the thread: I have a more realworld requirement similar to the above requirement is:
    Manage bank transactions for clients. and give invoices to clients according to their transaction records. One invoice can contain one or many transactions records. and one transaction records can be split into many invoices.
    Regards
    bao
    Edited by: user6715237 on 2013-4-19 下午11:18
    JAVE->JAVA

  • Column names from another table

    Hi All,
    I have a scenario where i need to get names of a column from another table
    for eg,
    Table EMP
    EmpNo EmpName EmpContact EmpPhone
    1 xyz [email protected] 345     
    2 abc [email protected] 897
    3 ttp [email protected] 345
    The column names of this table can be configurable from some other place and its value is stored in another table like
    Table Config (2 Columns)
    Column_Name Value
    EmpName First name
    EmpContact Email
    EmpPhone Mobile
    Now i want to fetch the values from Emp table but with column headers that are changed and have a value in Config table.
    If a column name is not there in config table then the original column name should come.
    As shown below
    EmpNo First name Email Mobile
    1 xyz [email protected] 345
    2 abc     [email protected] 897
    3 ttp [email protected] 345
    Another eg, If EmpName is not changed and entered in second table , then i want to have the same name as the original EMP table has as shown below.
    EmpNo EmpName Email Mobile
    1 xyz [email protected] 345
    2 abc     [email protected] 897
    3 ttp [email protected] 345
    In other words something like this,
    select empno,
    EmpName as (select value from config where column_name=EmpName),
                   EmpContact as (select value from config where column_name=Empcontact),
                   EmpPhone as (select value from config where column_name=EmpPhone)
         From EMP
    Can some one please help me in providing a solution for this.
    Edited by: 941386 on May 30, 2013 6:20 AM

    Unfortunately, I think this is a job for dynamic sql ...
    Build your "query" first:
    (note this won't work "as is", fix the syntax - but you get the idea.)
    lv_str := 'select empno,
    EmpName as ' || (select value from config where column_name=EmpName) || ',
    EmpContact as ' || (select value from config where column_name=Empcontact) || ',
    EmpPhone as ' || (select value from config where column_name=EmpPhone) || '
    From EMP;';
    execute immediate lv_str;Not sure if there's a better way or not.
    Only other way I can think of is to leverage the way UNION [ALL] works.
    So the following query:
    select a, b, c from dual
    union all
    select d, e, f from dual
    /returns data in columns "named" : "a, b, c"
    Effectively renaming columns d, e, f. You just need to turn your data on edge in that first query, then throw out the rows (I don't know how to get it to work, but perhaps somebody else does?)
    [edit]
    another thought is create a view over top of the table, query that view, then drop the view :P
    that would work nicely - avoid the dynamic SQL. shrug
    [edit]
    Edited by: Greg.Spall on May 30, 2013 9:37 AM

Maybe you are looking for

  • CC&B LoginModule for Weblogic Change of Password

    Hi All, I realise this is more of a Weblogic question, though I'm specifically after a working example of LoginModule that can be used within CC&B on Weblogic to: a) Force users to change their password if their password is reset; b) Force users to c

  • Itunes doesnt detect ipod but has with different ipod

    I just bought a used apple ipod after my old one was dropped in my drink and shorted out. I downloaded the ipod updator like it told me after saying that i needed for itunes to detect my ipod and restarted my computer after installing. Even this new

  • Mapping multiple tags

    Hi, I am dealing with a mapping challenge. I have my incoming message <address> <name1> A</name1>             (occurrence is 0:1) <street1>ABC Street</street1> <name2>P</name2> <street2>PQR Street</street2> <name100>X</name100> <street100>XYZ Street<

  • How can I show my scanner in Photoshop import menu?

    How can I show my scanner in Photoshop import menu?

  • How many methods copies will create when i create multiple objects

    Hi I have big doubt in java. See the following Program class A{ public int i; public static int j; public void methodOne(){ Sytem.out.println("Welcome"); public static void methodTwo(){ System.out.println("Welcome methodOne"); class B{ public static