KEY-EXEQRY trigger and FROM CLAUSE QUERY problem

Hi,
I have a form designed in Oracle Forms6i. I have two block on it, BlockA and BlockB.
When BlockA is queried with some data to search, I need to build the FROM CLAUSE QUERY for BlockB. It uses the same WHERE condition as I used to search BlockA.
I am building the FROM CLAUSE QUERY and executing query for BlockB on KEY-EXEQRY trigger of BlockA.
It works fine, if first time, I query the BlockA without any specific data. But it gives me error 'ORA-01008: not all variables bound' if I query the BlockA with specific data very first time.
Please advise.
Thanx
Zaaf

No, I am not using any substitution variables. To get the LAST_QUERY for BlockA, I am using Get_Block_Property.
But now I switched it to :system.LAST_QUERY and it worked.
Thank you!

Similar Messages

  • From Clause Query problem

    The query should fetch 2 rows for this item.
    but instead fetching no rows
    SELECT B.JOB_CODE, A.CLASSIFICATION_CODE, A.ITEM_ABBR,
    A.ITEM_DESC, A.ALT_ITEM_CODE, A.UOM_DESC,
    A.BASIC_PRICE, (A.OPENING_QTY + (NVL(B.ACC_QTY, 0)
    + NVL(F.RET_IN, 0)) - (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT,
    0))) AS OPENING_STOCK, (NVL(D.ACC_QTY, 0)
    + NVL(H.RET_IN, 0)) RECEIVED, (NVL(E.ISS_QTY, 0)
    + NVL(I.RET_OUT, 0)) ISSUED,
    ((A.OPENING_QTY + (NVL(B.ACC_QTY, 0) + NVL(F.RET_IN, 0))
    - (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT, 0)))
    + (NVL(D.ACC_QTY, 0) + NVL(H.RET_IN, 0)) - (NVL(E.ISS_QTY,
    0) + NVL(I.RET_OUT, 0))) QTY_IN_HAND
    FROM (SELECT CLASSIFICATION_CODE, ITEM_ABBR, ITEM_DESC,
    ALT_ITEM_CODE, UOM_MASTER.UOM_DESC,
    BASIC_PRICE, 0 OPENING_QTY
    FROM ITEM_MASTER, UOM_MASTER
    WHERE ITEM_MASTER.UOM_CODE = UOM_MASTER.UOM_CODE)
    A,
    (SELECT GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE < '01-JAN-2006'
    GROUP BY GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE) B,
    (SELECT B.TO_JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE < '01-JAN-2006'
    GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) F,
    (SELECT MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE < '01-JAN-2006'
    GROUP BY MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE) C,
    (SELECT B.JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE < '01-JAN-2006'
    GROUP BY B.JOB_CODE, B.ITEM_CODE) G,
    (SELECT GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE) D,
    (SELECT B.TO_JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE BETWEEN '01-JAN-2006' AND
    '31-DEC-2006'
    GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) H,
    (SELECT MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE) E,
    (SELECT B.JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE BETWEEN '01-JAN-2006' AND
    '31-DEC-2006'
    GROUP BY B.JOB_CODE, B.ITEM_CODE) I
    WHERE A.ALT_ITEM_CODE = B.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = C.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = D.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = E.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = F.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = G.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = H.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = I.ITEM_CODE (+) AND
    B.JOB_CODE = C.JOB_CODE AND
    B.JOB_CODE = D.JOB_CODE AND
    B.JOB_CODE = E.JOB_CODE AND
    B.JOB_CODE = F.TO_JOB_CODE AND
    B.JOB_CODE = G.JOB_CODE AND
    B.JOB_CODE = H.TO_JOB_CODE AND
    B.JOB_CODE = I.JOB_CODE AND
    A.ALT_ITEM_CODE = 'BOSNVL0004-006-002';
    ...

    3 posts...in the same forum?

  • FROM Clause Query and Invisible records :(

    HI:
    My form has a block based on a FROM clause query (QUERY DATA SOURCE TYPE).
    This works fine with no errors. Count hits suggests that it is retrieving records but my Item is not displaying the records. I have nine records in total but all fields are blank even though I can 'scroll' through the nine (invisible) records.
    Strange, any ideas people ?
    thanks.
    N.

    Thanks you for the reply but its not the cause of the 'probem'. My items are in a multi record block ( I have tried single item bock / No Items displayed 1 etc..) but to no avail.
    The strange thing about it is that I can Message(:blk.item) and the value displays on the Message bar but there are no values displayed in the Canvas Item at runtime ????? Very strange or does someone know something I dont.
    I can even scroll to the end of the record set ( 9 recs).
    I have never caome across this before has anyone else ?
    Thanks
    N.

  • Block based on "From clause query" and substitution variable

    Hi Folks,
    I have a "From clause query" block type, which is based on query that uses a substitution variable (:BLOCK.COLUMN) from previous block. When I run a query, then I obtain an error: ORA-01008: not all variables bound.
    My query looks like:
    select seq_no, prod_code, descr, curr_code,
           max(decode(sched_type_code,'ROLLOVER',amt,0)) OUTSTD_DRAW,
           max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) OUTSTD_INTEREST_FEE
    from
        select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
          from repay_scheds r,
               fac_prods f
         where r.fac_no = f.fac_no
           and r.prod_code = f.prd_code
           and r.prod_seq_no = f.seq_no
           and r.fac_no = :B2.FAC_NO
           and r.trans_ref_from is not null
           and r.status         <> 'P'
        group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code 
    group by seq_no, prod_code, descr, curr_code
    having max(decode(sched_type_code,'ROLLOVER',amt,0)) >0 or max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) > 0Once I replace that substitution variable in query condition with some exact test number then it works fine.
    select seq_no, prod_code, descr, curr_code,
           max(decode(sched_type_code,'ROLLOVER',amt,0)) OUTSTD_DRAW,
           max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) OUTSTD_INTEREST_FEE
    from
        select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
          from repay_scheds r,
               fac_prods f
         where r.fac_no = f.fac_no
           and r.prod_code = f.prd_code
           and r.prod_seq_no = f.seq_no
           and r.fac_no = 2012500
           and r.trans_ref_from is not null
           and r.status         <> 'P'
        group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code 
    group by seq_no, prod_code, descr, curr_code
    having max(decode(sched_type_code,'ROLLOVER',amt,0)) >0 or max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) > 0How can I use substitution variable within query for "From clause query" block type? Or any other way how to get the same result?
    Thanks for your reply.
    Tomas

    I have a solution:
    Before entering block I'm calling function, that populates my block:
    PROCEDURE POP_<<MY_BLOCK>>_BLOCK IS
      query_txt varchar2(2000);
    BEGIN
       query_txt := '(select seq_no, prod_code, descr, curr_code,
                            max(decode(sched_type_code,''ROLLOVER'',amt,0)) OUTSTD_DRAW,
                            max(decode(sched_type_code,''INTCHG'',amt,decode(sched_type_code,''FEEREC'',amt,0))) OUTSTD_INTEREST_FEE
                                                  from
                                                     select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
                                                       from repay_scheds r,
                                                            fac_prods f
                                                      where r.fac_no = f.fac_no
                                                        and r.prod_code = f.prd_code
                                                        and r.prod_seq_no = f.seq_no
                                                        and r.fac_no = '||:B2.FAC_NO||'
                                                        and r.trans_ref_from is not null
                                                        and r.status         <> ''P''
                                                     group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code 
                                                 group by seq_no, prod_code, descr, curr_code
                                                 having max(decode(sched_type_code,''ROLLOVER'',amt,0)) >0 or max(decode(sched_type_code,''INTCHG'',amt,decode(sched_type_code,''FEEREC'',amt,0))) > 0)';
       Go_Block('<<MY_BLOCK>>' );
       Clear_Block ;
       Set_Block_Property( '<<MY_BLOCK>>', QUERY_DATA_SOURCE_NAME, query_txt) ;
       -- populate my  block --
       Execute_Query ;
    END;Thanks,
    Tomas

  • From Clause query with form variables

    forms 9.0.4 rdbms 9.2
    Is it possible to create a From Clause query with form variables generated from another block (but in the same form)? I am not having any success.
    I searched Metalink. It appears that according to DOC ID # 69884.1, in Forms 6i, this is not possible. Metalink suggest in DOC ID 104771.1 implementating a dynamic From Clause, but when I duplicate the example on my system, I receive an Oracle error. Further investigation from the web form (DISPLAY ERROR) indicates that the system does not see the dynamic value.
    Has anyone else run into this error? Has this been fixed in forms 9.0.4 and I am just missing something? Does a dynamic from clause query work? Can anyone point me to an example or post an example or offer any advise.
    thanks in advance

    As far as I know it is not possible to use block items in a from clause query in forms 9.0.4. Here is my solution for a From-Clause-Query via the 'Query-Data-Source-Name-Property':
    To use the values of the block items in my from clause query I implemented a database package with getter and setter routines for the block item values I needed for the query.
    In the Key-Exeqry-Trigger of the From-Clause-Query-Block I set the global package variables with values of the block-items I am interested in. In the From-Clause-Query I used the values in the where-clause via package functions which return the global package variables.
    Hope my solution will work for your problem.

  • From clause query works ok in form designer,  gets an ORA-01422 ran on web

    I am using forms 6i patch 9 with 10g database.
    I have two ‘FROM clause queries’ fired via a block/key-exeqry trigger in a if/elsif.
    The first/top SET BLOCK PROPERTY works perfect and populates the block.
    But the bottom/second SET BLOCK PROPERTY select (after the elsif)
    Is also based on a user entered field value and generates a ora-01422 error.
    The problem is that both top and bottom set block properties
    work fine when ran in forms designer,
    But when I compile it on the app_server and run the web version
    1. the top all ‘FROM clause query’ works fine
    2. the bottom ‘FROM clause query’ works fine if only one record to return.
    3. the bottom ‘FROM clause query’: gets the ora-01422 if > 1 record to return.
    FRM-40735: KEY–EXEQRY trigger raised unhandled exception ORA-01422
    The ORA-01422: ‘Exact fetch returned more than the exact number of rows’.
    Both set block property selects ‘share’ a block property/where clause of FAC_ID = :FACILITIES.ID
    The entered value in the entry field should populate 1 to many associated records
    in the bottom (elsif) set block property (and does so correctly when ran in forms designer)
    The block’s key-exeqry code:
    –-query all records associated with fac_id only
    if (:emission_stacks.stack_id_num is null) then
         SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID,A.FAC_ID,A.NUM,A.DESCRIPTION,C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL)');
    EXECUTE_QUERY;
    elsif
    (:emission_stacks.stack_id_num is not null) then
    –-(query all records associated with fac_id and the entry field value)
    SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID, A.FAC_ID, A.NUM, A.DESCRIPTION, C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C,
    STACKS S
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.STACK_ID = S.ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL AND
    S.NUM = '''||:emission_stacks.stack_id_num||''')');
    EXECUTE_QUERY;
    ** I have multiple database items in the block.
    Data block properties:
    Database/
    Data Base Block = Yes
    Query Allowed= Yes
    Is there a way to overcome the ora-01422?
    And populate the block with multiple rows(records)?
    Any suggestions appreciated.

    Sorry, false alarm, I made a mistake
    the form is working fine the way it should,
    without error. (No ora-01422 errror is occurring now.)
    I just got a new version of humming bird,
    which I used to compile the form with
    and did not have the binary switch on:
    --long story short, a new fmx was not created
    and I was not seeing the current version of screen
    at runtime.
    Thank you.

  • Record Group and From-Clause Datasource

    I need to do several complex queries (read-only) for my form. Original I used From-Clause datasource but, as the requirement changed, there are some limitations. I would rather no do anything dynamically if as all possible because there are over 20 such queries which makes the code difficult to maintain. I wanted to be able to reference block items in the query.
    I'm thinking about using Record Group query instead. What are the differences in capability between Record Groups and From-Clause Datasource?
    Thanks.
    Clayton.

    Thanks.
    That's exactly the problem I have. I don't want to use LOVs so I've been thinking about how to visualize the record group data using data blocks. Perhaps I'll just go with dynamically building the From-Clause.
    I've looked into stored procedure based blocks a bit; it was confusing for me. Are the stored procedures stored in the database or are they defined in the form?

  • Master detail with from clause query

    Hi!
    I have 2 blocks: master and detail. The master block is based on a from clause query. Since I have to insert, update and delete on this block I have created the on-insert, on-update, on-delete and on-lock triggers (and the respective procedures).
    In this block I have on-populate-details and pre-delete triggers created by the master-detail relation.
    Now I have a problem!
    Since I only want to commit to db when I click the "ok" button and I want to insert and delete records from these 2 blocks, when I insert records into the detail block (and master too), it forces me to save changes if I change the focus of the current record of de master block to another record within the same block.
    How can I do this in order to insert records saving changes only when I click the button?
    Thanks!
    Ana

    I think that it is intended behaviour: when detail records are populated and there are uncommited changes so Forms asks if user wants to save changes.

  • FROM CLAUSE QUERY, how to construct?

    Have always used the data block wizard so am probably missing something quiet simple. I have created a new form and am manually creating a simple test block. What i've done so far:
    Block Properties
    Database Data block: No
    Enforce Primary Key: Yes
    Query allowed: Yes
    Query data source type: FROM clause query
    Query data source name: select department_id, department_name from departments
    Query data source columns: department_id (number), department_name (varchar2)
    Created a canvas with and put two items, department_id (set as Primary key) and department_name on it.
    When i run the form i get... FRM-41003 This function cannot be performed here.
    What am i doing wrong and what steps should i be taking?
    Gus
    Oracle 10g

    first of all you should set the DATABASE DATA BLOCK property to YES, not NO.
    it is a database block though not based on a TABLE, rather on a FROM CLAUSE QUERY, but it is a database block.
    another thing, when you run the form, what function you are trying to perform when you get the error: "FRM-41003 This function cannot be performed here."
    i guess you are trying to query the data. if its same, then that should be resolved once you set the DATABASE DATA BLOCK to YES.

  • From Clause Query

    Designer Version 6.5.95.4.8
    Configuration: 4.0.12
    Release 4.10
    Database 10g
    Forms [32 Bit] Version 6.0.8.25.2 (Production)
    Can someone help me with From Clause query in Designer?
    Designer Help files do not seem to cover this in depth.
    Here is what I did so far.
    1. Created module component
    2. Set Datasource Type to Query
    3. Code to set the query at run time:
          GO_BLOCK('LINK_DTL');
          CLEAR_BLOCK(NO_VALIDATE);
          vFromClauseQuery := '(SELECT DISTINCT p_code, e_code '||
                               'FROM code_table '||
                               'WHERE L_YEAR = '||:LINK.l_year||' AND L_SEQ = '''||:LINK.l_seq||''')';
          SET_BLOCK_PROPERTY('LINK_DTL',QUERY_DATA_SOURCE_NAME,vFromClauseQuery);
          DO_QUERY;   
    Also I created unbound columns :p_code and :e_code for the block, to receive the results from the query (is that the correct way to do it?)
    When I run the form, my block is empty, and if I open the form in form builder, the block that I had set to have datasource of "query" has datasource type of "table" ???
    Thanks

    Bind variables cannot be referenced in from clause query (this is a bug/enhancement 767062).
    But, in PRE-QUERY trigger we can write built-in
    SET_BLOCK_PROPERTY (block_name, QUERY_DATA_SOURCE_NAME, value);
    For example:
    DECLARE
    l_deptno dept.deptno%TYPE := 50;
    l_from_clause VARCHAR2 (1000);
    BEGIN
    l_from_clause :=
    '(SELECT deptno, dname, loc FROM dept WHERE deptno < ' || l_deptno || ')';
    SET_BLOCK_PROPERTY (:SYSTEM.TRIGGER_BLOCK, QUERY_DATA_SOURCE_NAME, l_from_clause);
    END;
    Regards,
    Zlatko Sirotic

  • Form blows up when clicked in data block using a FROM clause query

    Hi,
    I have a form that has two blocks. The detail block is based on a "FROM query clause" in the 'Query Data Source Type' in the block Properties.
    I have a simple select in the 'Query Data Source Name'.
    I made sure the select is enclosed in parenthesis and the alias names in the SELECT are the same as the ITEMS defined in the block
    The data needs to be displayed in a tabular fashion.
    When I run the form, the data is displayed correctly..but when I click the mouse on any item of this block or try to scroll down, everything just blows up and it closes my form.
    I have made sure both blocks have the same properties. But, this seems to happen no matter what.
    Any help in regard is greatly appreciated.
    Thanks much,
    Vijji

    This is how I set the relationship for the detail block say BLOCK2.
    1. I first do this:
    Database Data Block = YES
    Query Allowed = YES
    Query Data Source Type = FROM clause query Query Data Source Name = ( select jio.order_header_id order_header_id, jii.item_code item_code, SUM(jii.item_qty) item_qty from joe_indv_items jii, joe_indv_orders jio where jii.indv_order_id = jio.indv_order_id group by jio.order_header_id, jii.item_code )
    The master and detail need to be tied by the order_header_id which I can get from the header block.
    2. In the WHEN-NEW_BLOCK-INSTANCE trigger for BLOCK2, I wrote the following where I dynamically pass the order_header_id:
    DECLARE
    q varchar2(1000);
    BEGIN
         q := '(SELECT jio.order_header_id order_header_id,
         jii.item_code item_code,
         SUM(jii.item_qty) item_qty
         FROM joe_indv_items jii, joe_indv_orders jio
         WHERE jio.order_header_id = ' || :HEADERS.order_header_id||'
         AND jii.indv_order_id = jio.indv_order_id
         GROUP BY jio.order_header_id, jii.item_code )';
         CLEAR_BLOCK;
    SET_BLOCK_PROPERTY('BLOCK1', QUERY_DATA_SOURCE_NAME, q);
    EXECUTE_QUERY;
    END;
    I am not sure if I should write the exact select statement in the Query Data Source Name or not.
    Please advice.
    Thanks much,
    Vijji

  • Insert in a "FROM clause query" block

    I have a block based on "FROM clause query" (querying two different tables). I want to be abble to insert in this block. I wrote the DML code to insert in both tables, but I then need to stop forms who try to insert by itself, because it fails and rollback my change. How can I do this ?

    If you have Oracle Server 8.1.6+ you can
    create a database view with these two tables
    and create a "instead of" trigger to insert
    in both tables. It will be faster to
    execute, your Forms becomes simpler and it
    is easier to manage. Example from the
    Oracle Server documentation :
    CREATE TABLE customers_sj
    ( cust NUMBER(6),
    address VARCHAR2(50),
    credit NUMBER(9,2) );
    CREATE TABLE customers_pa
    ( cust NUMBER(6),
    address VARCHAR2(50),
    credit NUMBER(9,2) );
    CREATE TYPE customer_t AS OBJECT
    ( cust NUMBER(6),
    address VARCHAR2(50),
    credit NUMBER(9,2),
    location VARCHAR2(20) );
    CREATE VIEW all_customers (cust)
    AS SELECT customer_t (cust, address, credit, 'SAN_JOSE')
    FROM customers_sj
    UNION ALL
    SELECT customer_t (cust, address, credit, 'PALO_ALTO')
    FROM customers_pa;
    CREATE TRIGGER instrig INSTEAD OF INSERT ON all_customers
    FOR EACH ROW
    BEGIN
    IF (:new.cust.location = 'SAN_JOSE') THEN
    INSERT INTO customers_sj
    VALUES (:new.cust.cust, :new.cust.address,:new.cust.credit);
    ELSE
    INSERT INTO customers_pa
    VALUES (:new.cust.cust, :new.cust.address, :new.cust.credit);
    END IF;
    END;
    null

  • Changing DEFAULT_WHERE of a FROM CLAUSE Query (with group by)

    I have a Data Block of type FROM CLAUSE Query.
    The Data Source Name is
    SELECT A2.NAME,A2.EMPLOYEEID,A1.ORGID,A1.FSCLYEARID,A1.STATUS,COUNT(*) AS COUNTER
    FROM S_PLC10300 A1,S_PLC50200 A2
    WHERE A1.EMPLOYEEID=A2.EMPLOYEEID
    GROUP BY A1.ORGID,A1.FSCLYEARID,A1.STATUS,A1.EMPLOYEEID,A2.NAME,A2.EMPLOYEEID
    I have a Query Area with text items which i use to change the DEFAULT_WHERE Property.
    My problem is that i can' t put in the DEFAULT_WHERE a field that doesn't belong to the SELECT Clause. Is there a way to achieve this?
    Maybe changing the whole Data Source Name at runtime ?
    Thanks

    As I said i have a block with FROM clause query:
    SELECT A1.ORGID,A1.FSCLYEARID,A1.STATUS, A1.EMPLOYEEID, A2.NAME,A2.EMPLOYEEID
    FROM S_PLC10300 A1,S_PLC50200 A2
    WHERE A1.EMPLOYEEID=A2.EMPLOYEEID
    GROUP BY A1.ORGID,A1.FSCLYEARID,A1.STATUS,A1.EMPLOYEEID,A2.NAME,A2.EMPLOYEEID
    i use the following code:
    set_block_property(BLOCK,DEFAULT_WHERE,'A1.TRNSDATE>=:QUERY_BLOCK.TRNDATE);
    What i think the code will do is change the FROM Clause Query to:
    SELECT ... WHERE A1.EMPLOYEEID=A2.EMPLOYEEID AND A1.TRNSDATE>=:QUERY_BLOCK.TRNDATE
    GROUP BY ...
    A1.TRNSDATE is a valid field of table A1.
    I can' t add TRNSDATE to my SELECT clause because i will have to add it to the GROUP BY clause.
    Hope i made more sense this time.
    Thanks

  • URGENT : online views for from clause query

    Hi all,
    I do not know why this query does not return any rows ! There are two online views in the from clause of the query . Each query returns rows , but when I include them in the from clause query then no rows are returned :
    Here are the results of each online views :
    select rdv_id,typerdv_id,count(rdv_finalite) nb_ok from rdvs where rdv_finalite='OK' group by rdv_id,typerdv_id;
    RDV_ID TYPERDV_ID NB_OK
    41 1 1
    select rdv_id,typerdv_id,count(rdv_finalite) nb_ok from rdvs where rdv_finalite='KO' group by rdv_id,typerdv_id;
    RDV_ID TYPERDV_ID NB_OK
    41 1 1
    And here is the query with the two online views in the from clause query :
    select to_char(r.rdv_date_effective,'Month') mois,ok.nb_ok nbok,ko.nb_ko nbko
    from rdvs r,
    (select rdv_id,typerdv_id,count(rdv_finalite) nb_ok from rdvs where rdv_finalite='OK'
    group by rdv_id,typerdv_id) ok,
    (select rdv_id,typerdv_id,count(rdv_finalite) nb_ko from rdvs where rdv_finalite='KO'
    group by rdv_id,typerdv_id) ko
    where r.rdv_id=ok.rdv_id and ko.rdv_id=r.rdv_id
    order by mois DESC;
    aucune ligne sélectionnée
    So where is the problem in my query ?
    Thank you very much

    For the first query here is the result :
    RDV_ID TYPERDV_ID NB_OK
    29 1 1
    For the second query :
    RDV_ID TYPERDV_ID NB_OK
    41 1 1
    Sorry

  • From Clause Query block

    I'm using a from clause query block.
    I'm being prompted to use a on-lock trigger, if I have to update an item in my said block.
    1.What is the purpose of on-lock trigger in the given scenario, can I just use a null in the trigger.
    2.Further, why is it necessary to set the database item property to yes for all items in a from clause query block?

    The nature of use of the said from clause query based form I have explained above is that it is used to primarily set a No_change_flag from the screen in different loan type tables.
    If the concerned user decides that a loan should not be modified, he will come to this screen and query for that loan type, and check the no_change_flag. Then from the when button pressed trigger we go and update that respective loan type table and set the no_change_flag to YES.
    We have 4 loan type tables.Some times the user might choose to query by loan_date , and that will return multiple loans belonging to multiple loan types. In such a scenario we update multiple loan tables wherein the loan
    should not be changed.
    Actually we loop through the block and if the no_change_flag is chekced to YES, and then we update that respective loan type table. Yes when we are looking and issuing updates, and before the commit_form is issued at the end of the loop, in between some other user tries to update the row locked for update by us, then they will automatically get the appropriate message.
    I dont see the need in the above case to code anything else than NULL;
    Do anyone see this in a different way, or I'm I missing any impact the above functionality might cause?

Maybe you are looking for