Query on Data Block based on View

Hi,
I am new to forms and am trying to modify an existing form which currently works in the following way :
The same form is used for insert/updates/queries.
The data block is based on a table and a post query trigger is written which updates the other text items on the canvas(which come from different tables) based on the values returned by the data block. Since the query functionality is based only on the table, you cannot query on the other items that are on the canvas. I need to make the query work on the other items that come from different tables.
I created a view which joins all the tables but when I query although it returns the right record I get an error message " Cannot insert into or update view"
I'm not sure what the best way to resolve this is ?
Any suggestions ?
Thanks
Preeti

Thanks for the replies.
I created an updateable view and an instead of trigger. The Form is now queryable on all fields and the insert to the table works beautifully.
However, now I'm getting an error on Update. Updating any column on the form results in a
ORA-01733: virtual column not allowed here
FRM-40501: ORACLE error: unable to reserve record for update or delete.
The code for the view is :
select a.*,
B.vendor_name as Supplier_name,
     'PRE' AS TO_OWNER,
     C.vendor_site_code as supplier_site,
     ARCH.vendor_name AS Architect,
     p.segment1 as Project,
     ph.segment1 as PO_number,
     decode(a.interface_status,'I','Interfaced', 'U', 'UnInterfaced',
     'P', 'Partial',null) Interface_display_status,
     decode(a.approval_status,'A','Approved', 'P', 'Partial',
     'R', 'Rejected', 'U','Unapproved',null) Approval_display_status
from idc_aia_g702 a, po_vendors b,
po_vendor_sites_all C,
PO_VENDORS ARCH,
pa_projects_all p,
po_headers_all ph
where b.vendor_id = a.vendor_id
AND A.vendor_site_Id (+) = C.vendor_site_id
AND A.VIA_ARCHITECT_VENDOR_ID = ARCH.VENDOR_ID (+)
and a.project_id = p.project_id
and a.po_header_id = ph.po_header_id;
I know I have to do something on either the data block property palette or the individual item property palette and clicking on any field within the form in order to update it results in the error mentioned above.
Shd I have all the item props as Query Only set to Yes ? or the ones for Table A as Query Only set to N and the other table columns as Y ?
Thanks
Preeti

Similar Messages

  • Updating record in a data block based on view in oracle forms

    hi all ,
    We have two data blocks in our custom oracle form.The first data block is for search criteria provided with buttons 'GO' and 'ADD ROW' and the second data block is based on a view that fetches record when user clicks on GO based on the the criteria specified in the above block. The Below block contains one SAVE button too.
    We have a requirement when GO button is pressed and corresponding records are shown in the below block, user should be able to edit the record. Want to know how to make it editable?
    Help appreciated....!!!

    Your view is based on how many tables and does it include all NOT NULL fields from all tables?

  • Inserting/updating data in control block based on view

    Hi!
    I`ve created a block based on a view to display data.
    I want this block to be insertable and updateable, that is I will use a on-insert/update trigger to call an insert/update procedure located in the database.
    When trying to change/insert a value in the block, the error message "Error: Can not insert into or update data in a view" pops up. I`ve tried to get rid of this error, without success.
    How can I make a data block based on a view insertable and updateable?
    My guess is that this have something to do with locking the records(there is no rowid in the view)... but I'm not sure.
    Pls advise!!

    Morten
    As well as on-update, on-insert, on-delete triggers you also need an on-lock,
    (even though it might just contain null;) otherwise the form will try to lock the view and fail.
    Actually your terminology is wrong, the block being based on a table or view is not a control block. A control block is not based on anything and has no default functionality for communicating with the database. If it was a control block, the on- triggers would not fire.

  • Query in data block

    hi,
    whether it's possible to write query in data block other than trigger.(i.e,.. data block created by the Wizard and executing a simple query over the data block based on a table)
    regards
    Yesukannan

    if i am right about u question , you can change your datablock sorce prooperty to QUERY and in soruce wirte ur query
    Block Property
    Database source- Query
    source table name:- write u query

  • Data Blocks Based on Stored Procedures

    Is it possible to to create a data block based on a stored procedure, and create a dynamic list as a drop down box?
    I have a form that runs successfully that has a data block based on a stored procedure. I add my trigger to create and populate the record group. Then in the Property Palette, when I change ITEM TYPE from TEXT ITEM to LIST ITEM, I receive the following runtime error:
    FRM-40350: Query caused no records to be retrived.
    Note: the tlist/list item runs successfully on a data block based on a table.

    1) go to the block property to remove the same item column, then re-add the item; Since the property may remember the old text type;
    make sure the record value for the list tiem from stored procedure is among the list elements!
    Last sort is to do:
    2) you may re-create your gui based on the table by setting the list type this time, then set the block property to be based on the stored procedure.

  • Forms9i, data block based on stored procedures, refresh on update ?

    Hi,
    I am using
    Forms [32 Bit] Version 9.0.2.9.0 (Production)
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
         With the Partitioning, OLAP and Oracle Data Mining options
         JServer Release 9.2.0.5.0 - Production
    Oracle Toolkit Version 9.0.4.0.23 (Production)
    PL/SQL Version 9.0.1.3.1 (Production)
    Oracle Procedure Builder V9.0.2.0.7 Build #1022 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle Query Builder 9.0.2.0.0 - Production
    Oracle Virtual Graphics System Version 9.0.1.5.0 (Production)
    Oracle Tools GUI Utilities Version 9.0.4.0.9 (Production)
    Oracle Multimedia Version 9.0.4.0.9 (Production)
    Oracle Tools Integration Version 9.0.2.0.0 (Production)
    Oracle Tools Common Area Version 9.0.1.0.0
    Oracle CORE     9.0.1.2.0     ProductionI have a module based on stored procedures. I have defined query, lock and update procedure. All of them are working as they should, I mean that when looking at the input and output from these procedures I don't see anything blatantly wrong.
    Now, when I update a table field in the form and call the update stored procedure, this procedure takes the updated values in considerations, updates some more fields, and remove some records.
    It is working as it should, except for two details :
    1- I don't see the values updated by the procedure in the Form;
    2- even though some records were removed from the table by the procedure, I still see all my records.
    Is there a way to display the returned table?
    And, is there any documentation about data block based on stored procedures, what are the required signatures and limitations of those stored procedures, what a lock procedure is supposed to do (mine does 'null;' ...), how to map a collection type defined in Oracle to a Form data block ? Any link will be appreciated, I have found half a dozen page vaguely detailing this on Google, but nothing that can compare to a usual Oracle manual. Maybe I have missed something.
    Thank you for your help.
    adsm

    Yes, I was hoping to use these procedures to map the collection type returned to the database to the block data. I guess I was wrong. Except for the initial query and reading some other information from the database, I don't have to use these procedures as I do not write anything to it.
    Thank you for your help, I will go on from there.
    So, it means that I will have to iterate through my collection inside Forms and manipulate my data row by row. Or, is there a way to pass an Oracle collection type between the database and the Forms client and have it displayed without having to iterate through the rows and mapping each field?
    adsm

  • Query a database block based on a non-database block

    hi everybody
    can anybody help me as how to query a database block based on a non-database block, without a master-detail relationship?
    i have a block : date_input which contains a non-database item: start_date
    another database block (event_block)containing details of an event
    i have to input a date in the start_date and query the event_block
    in wich trigger should i insert the code?
    thanks

    If you are trying to query your database block (event_block) using the value from start_date in your non-database block, then you can set the Where clause in the database block using:
    SET_BLOCK_PROPERTY ('event_block', DEFAULT_WHERE, 'your where clause that includes start_date');
    Place this statement in a trigger that is executed prior to the block being queried.

  • Data block based on stored procedure with  input arguments

    Hi,
    I am able to create a data block based on stored procedure.
    but I want that procedure to take input arguments as well and I am facing the issue while setting the value for that input arguments from another block item.
    Please somebody help, How to set the value for input argument from another control block- item?.(Note :Data block is based on the stored procedure)
    Thanks in Advance,
    Anandan Muthukannan

    I did exactly the same way you mentioned.
    But while building the form, The call to the procedure in 'QUERY-PROCEDURE' trigger has been modified like this way
    procedure_name(qp_data,':BLOCK.ITEM');
    so in procedure i am getting the value as ':BLOCK.ITEM' not the expected value.

  • Data block based on procedure

    While working on a form with a data block based on a procedure, I keep getting error
    FRM-40364 The data type of item '%' does not match the corresponding column in the stored procedure.
    I have compared the items many times and found no mismatch. When the items are resorted (in both the data block and the procedure) and everything is recompiled, the
    "not matching" item referenced sometimes changes, though the types have not been changed. Has anyone solved a similar situation?

    Hi,
    Yes I did use the wizard,
    I agve it the package.proc name for query.
    it pulled up the field delivery ID,
    Hit finish, because I do not need update/delete/inserts.
    the query data source columns and arguments was defaulted correctly.
    THe QUERY-PROCEDURE was built by default.
    It is giving me an error though: wrong number or types of arguments in call to POPULATE_BLOCK..
    DECLARE
    bk_data HSM_WSH_DEL_UTIL.DEL_TBL;
    BEGIN
    hsm_wsh_del_util.do_query(bk_data);
    PLSQL_TABLE.POPULATE_BLOCK(bk_data, 'NEW_DELIVERIES');
    END;

  • Does adding a field to a table affect a data block based on the table?

    If I make a change to a table like adding a field does it affect data data blocks based on the table?

    The other place I have seen where adding a new column to a table causes problems is when a programmer codes: Select * from table.
    If that is coded in a form, the form will need to be recompiled before it will work properly.

  • Block based on view ,enter query

    Hi,
    I have a block based on a view.One column of the view is
    substr(f_gt_marks(tcs23.idu_nr_dossr),1,128).
    When I enter 'PAPER%' for the above column and press execute query i get:
    PAPER
    PAPER1PAPER2
    When the form is in enter query mode and when I enter 'PAPER' and press execute query I get FRM 40301 query caused no rows to be retrieved.
    I want only paper to be retrieved.The form works only if I append % to the search criteria.
    Can you please advise me.
    I am working on forms 9i.
    Thanks and Regards

    Try to debug for form, and get the SQL Statement that is being executed, see if it's doing anything out of the ordinary and try to run in SQL*Plus and see the result.
    I think your SQL is trying use the SUBSTR function on the value you enter in ENTER-QUERY mode.
    SUBSTR(f_gt_marks('PAPER'),1,128)Anyway, best for you to see what the form's SQL statement is when issuing the query.
    Tony

  • Problem updating data block based on a view

    Hi,
    I have a data block that is based on a fairly complex view, which I want to make update-able. The default Forms behavior, of course, is to not allow this.
    In an attempt to get around this, I defined an 'ON-LOCK' trigger, where I specified a single statement 'LOCK_RECORD;'. I also defined an ON-UPDATE trigger that will later call some stored PL/SQL procedures to effect the actual update (using INSTEAD-OF triggers and such). For now, I just display a message saying 'updation not currently supported'.
    However, a problem occurs when I make a change to an item in the data block, don't attempt to save it, yet try to navigate to the next record. The form simply hangs and the only thing I can do is kill the process.
    I'm deploying this form as within Oracle Apps 11i. I suspect this has something to do with the lock record but don't know how to get around this.
    Does any one have any suggestions?
    Thanks,
    Niranjan Ramakrishnan

    Your lock will be removed whenever the forms does a commit or rollback. In 'normal' forms processing the on-update trigger will fire as part of the commit form processing, which also includes a database commit which will remove any locks that have been taken out. Should the user clear the form a database rollback will be performed which will also remove any locks. You should not need to do any explicit removal of locks yourself.
    I would not recommend not having any kind of lock processing, as Sudha says, as this could easily lead to changes to record's being lost. As long as the locking of table(s) is always done in the same order deadlocking should not occur.
    You may make want to make the locking process a SELECT ... FOR UPDATE NOWAIT so if the record is already locked the user is informed and can try again later, rather than an unknown wait until the record becomes available.

  • How to query two data blocks simultaneously?

    Dear all,
    Need your inputs on the following problem statement...
    Existing Functionality:
    We have two data blocks A (Parent) and B (Child) in a relationship. Both data blocks refer to different tables.
    Data block A is the query data block and for a single record in block A we can have multiple records in block B. Multiple records in block B are shown one at a time after executing a query, this is implemented by using a list item C (belongs to a third block).
    For example
    Let us say block B can have 5 different types of entries for each record in block A. In this case the list item C will have 5 values corresponding to these entries. Once the query is executed, block B will show the default entry for the queried record in block A. To see other entries for the record user can select the required value in list item C and corresponding entry in block B will be fetched.
    Requirement:
    Our requirement now is to enable querying upon both data blocks A and B simultaneously. To implement this I replaced data blocks A and B with a single data block X which is based on the join of the two tables referred by the Data blocks A and B earlier. As the fields should allow insert, update, delete operations we did not use a view here.
    Issue:
    Now the problem is, each record in block A for which block B had multiple entries earlier is now getting listed multiple times because of the join.
    I have tried but could not find any solution for this. I would appreciate if any of you can suggest how we can query both blocks simultaneously without affecting the existing functionality.
    Thanks,
    Amit

    I don't understand your requirement in detail. I try to repeat what i understood so far.
    You have a master-block A based on a table A and a detail-block B based on a table B. So far so good. You can now query based on conditions just the datablock A, because B is a detail and therefore can only be queryied in context of block A.
    Your reuirement is to query on both blocks A and B and find block in B also without giving conditions for the relevant block A.
    Is it that ?
    What i don't understand, what is block C used for?
    An idea for the querying of block B's data: Create Non-database-items items in block A for the search-criteria you need on block B and make them Queryable.
    In the PRE-QUERY-trigger on block A build a WHERE-condition if that search-criteria is entered, something like
    IF :BLOCK_A.SEARCH_CRITERIA_FOR_BLOCK_B IS NOT NULL THEN
      SET_BLOCK_PROPERTY('BLOCK_A', ONETIME_WHERE, 'WHERE PKVALUE IN (SELECT FKVALUE_TO_A FROM TABLE_B WHERE FIELDVALUE=' ||:BLOCK_A.SEARCH_CRITERIA_FOR_BLOCK_B)');
    END IF;This would query also records to A for which you want to have the B-records. So you could keep block-structure up to master-detail.

  • Need to create a block based on view

    We can create a block based on procedure...but whats the need to do so...please can anybody explain.

    create the block with the data block wizard. Use your View as Data-Source.
    After that set all items to QUERY-ONLY, when they are not updateable. E.g. if you create a view from EMP to DEPT. Then it is not allowed to update DNAME. DNAME is set to QUERY-ONLY.

  • Help with Data Block Based on Procedure--getting compilation error

    I am trying to create a datablock based on a procedure , but im getting errors in compilation:
    Errors are :
    1) identifier 'HSM_WSH_DEL_UTIL.DEL_TBL' must be declared
    2)PL/SQL ERROR 320 at line 7, column 27
    the declaration of the type of this expression is incomplete or malformed
    ANy Help would be appreciated !
    Heres my pkg spec and body for the data block:
    CREATE OR REPLACE PACKAGE hsm_wsh_del_util IS
    TYPE del_record is record
    (delivery_id number);
    TYPE del_tbl is table of del_record INDEX BY BINARY_INTEGER;
    procedure do_query(p_del IN OUT del_tbl);
    END hsm_wsh_del_util ;
    CREATE OR REPLACE PACKAGE BODY hsm_wsh_del_util IS
    procedure do_query(p_del IN OUT del_tbl)
    IS
    idx number :=1;
    CURSOR DELIVERY IS
    SELECT DELIVERY_ID
    FROM abc_deliveries;
    begin
    FOR CUR IN DELIVERY LOOP
    p_del(idx).delivery_id :=cur.delivery_id;
    idx:= idx+1;
    END LOOP;
    end do_query;
    END hsm_wsh_del_util;
    Edited by: 981170 on Mar 13, 2013 1:08 PM

    Hi,
    Yes I did use the wizard,
    I agve it the package.proc name for query.
    it pulled up the field delivery ID,
    Hit finish, because I do not need update/delete/inserts.
    the query data source columns and arguments was defaulted correctly.
    THe QUERY-PROCEDURE was built by default.
    It is giving me an error though: wrong number or types of arguments in call to POPULATE_BLOCK..
    DECLARE
    bk_data HSM_WSH_DEL_UTIL.DEL_TBL;
    BEGIN
    hsm_wsh_del_util.do_query(bk_data);
    PLSQL_TABLE.POPULATE_BLOCK(bk_data, 'NEW_DELIVERIES');
    END;

Maybe you are looking for