Query based Data Block?

I have a situation where on the detail portion of the screen, I need to have fields from 2 tables shown that can be updated. The 2 tables are related through a foreign key. Can you have a data block based upon a query? If so, how... Thanks.

<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Richard Shannon ([email protected]):
I have a situation where on the detail portion of the screen, I need to have fields from 2 tables shown that can be updated. The 2 tables are related through a foreign key. Can you have a data block based upon a query? If so, how... Thanks.<HR></BLOCKQUOTE>
Hello,
there is two way to do the same. one is, you need to create a view in database based on both the tables and then create a data block based on that view. to update the value of specific column there is trigger instead-of, u can create this trigger on view and manipulate the corresponding table.
second is, create a data block based on virtual view same as fisrt one and write corresponding dmls in transactional trigger to update the information in actual tables.
i hope that it will help you to achieve the same.
take care
null

Similar Messages

  • 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

  • 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

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

  • Query on data block and Operating system block

    Hi ,
    Does data base requests data in term's of Data blocks or operating system block's . If data block's , how an data block get accessed the operating system block . what are the advantages over separating the data blocks from the operating system block's . can any one please explain the what happens once the data base requests the data ?
    Thank You

    sybrand_b wrote:
    This place is called 'Oracle Forum' It does not offer the Oracle University curriculum for free, nor does it offer free abstracts of the Oracle Concepts Manual.
    Kindly read the Concepts Manual of your unmentioned version yourself.
    Thank you.
    Sybrand Bakker
    Senior Oracle DBADear Sybrand
    As you said, this place is called Forum. If you know answer, then answer the question. If you know the documentation, then refer to documentation. If you don't know the answer, then don't answer in such rough manner! Just stop. Just don't type anything. Just be polity

  • Querying a data block

    HI,
    Can someone tell me how do I make non database fields on a form queryable?
    I have for example Country Name displayed on a form, but that is a non database item, the real database item is the country code. So when the user tries to query in this field, it doesnt return the correct results.
    Please assist
    Thanks
    s

    To query a block using a non-base table item, you have to modify the DEFAULT_WHERE clause of the block using the Pre-Query trigger of the block. In your situation, where you want to query records where the country code is equal to the country name selected, in your Pre-Query trigger your code would look something like this:
    /* Sample Pre-Query trigger - code is untested */
    DECLARE
       v_temp_where   VARCHAR2(500);
    BEGIN
       v_temp_where := 'COUNTRY_CD = (select country_cd from country where country_name = '||:YOUR_BLOCK.COUNTRY_NAME||')';
       /* Forms 6i */
       Set_Block_Property('YOUR_BLOCK', DEFAULT_WHERE, v_temp_where);
       /* Forms 9i or higher */
       Set_Block_Property('YOUR_BLOCK', ONETIME_WHERE, v_temp_where);
    END;Since you didn't specify your Forms version, I've given two options for setting the WHERE clause of your block.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Basing a Data Block on a Select Query

    Hi Folks,
    I'm trying to create a data block in Forms 6i, based on a from clause query which I give in the Query Data Source Name Property of the data block, but when I run the form the fields are blank and even when I execute the unrestricted query from the forms runtime environment, the fileds are still not populated and FRM-40505 error is given. Am I missing some basic stuff here?
    TIA
    Hassan

    Where do I go to see ALL_UPDATEABLE_COLUMNS? I'm not familar with that. (nevermind, i just spelled the object name wrong in my query)
    I think thats the way i'd like to go. But, i think i'll have to use the ON-Insert, ON-Update, etc. trigger method. But, I still can't seem to figure out how to get the view fields "editable" on the form.
    Message was edited by:
    ryan.moore

  • Insert and update a data block which is based on view--urgent help required

    Hi experts,
    I created a view(A_VIEW) which is based on a union select. I have created a data block A_VIW_BLOCK which is based on this view. I need to insert/update one of the base tablesfor A_VIEW through this data block. I also need to be able to make a query through all the fields in the view.
    The questions are:
    1.Can it be done at all?
    2. What properties need to be set?
    3. If can't be done, what the best approach to achieve this?
    Thanks in advance!!
    Michael

    hi
    try something like this.
    CREATE TABLE demo_tab (
    person_id NUMBER(3),
    first_name VARCHAR2(20),
    last_name VARCHAR2(20));
    CREATE OR REPLACE VIEW upd_view AS
    SELECT * FROM demo_tab;
    INSERT INTO demo_tab
    (person_id, first_name, last_name)
    VALUES
    (1, 'Daniel', 'Morgan');
    INSERT INTO demo_tab
    (person_id, first_name, last_name)
    VALUES
    (2, 'Helen', 'Lofstrom');
    COMMIT;
    SELECT * FROM upd_view;
    UPDATE upd_view
    SET person_id = person_id * 10;
    SELECT * FROM upd_view;
    desc user_updatable_columns
    SELECT table_name, column_name, updatable, insertable, deletable
    FROM user_updatable_columns
    WHERE table_name IN (
       SELECT view_name
       FROM user_views);
    SQL> create table dummy (f1 number);
    Table created.
    SQL> create view dummy_v 
    2  as 
    3  select f1 from dummy 
    4  union all  
    5  select f1 from dummy;
    View created.
    SQL> create trigger dummy_v_it 
    2  instead of insert 
    3  on dummy_v 
    4  for each row 
    5  begin 
    6    insert into dummy values (:NEW.f1); 
    7  end; 
    8  /
    Trigger created.
    SQL> insert into dummy_v values (1);
    1 row created.
    SQL> select * from dummy_v;       
    F1
    1        
    1
    SQL> select *
      2  from user_updatable_columns
      3  where table_name = 'DUMMY_V';
    OWNER    TABLE_NAME   COLUMN_NAME  UPD INS DEL
    FORBESC  DUMMY_V      F1            NO  NO  NOforms settings.
    Enforce Primary Key - No
    Query Allowed - Yes
    Query datasource Name - V_TSFDETAIL
    Insert Allowed - Yes
    Update Allowed - Yes
    Delete Allowed - Yes
    Locking Mode - Automatic
    Key Mode - Automatic
    do not forget to create synonyms.
    hope this helps.
    sarah

  • Forms clause query data source data block in oracle forms

    Hello experts,
                  I am new in oracle forms.I am using oracle forms 11g with weblogic 10.3.5 at windows 7.Through googaling I know how to create a database block,forms clause data block and stored procedure based datablock in oracle forms.I want to know that as in case of  Database based datablock, could we commit form either on editing records or on insertion or deletion in data block.
    I tried this but got error frm 40501.If we can perform editing and creation in such type of datablock then please tell me how.
    Thank You,
    regards
    aaditya

    When I base my datablock on a query using the "From Clause" property of the block query data source in the oracle Forms 6i,
    I get the strange error
    "ORA-00928: missing SELECT keyword"
    The query I see in the Display Error in Help Menu is
    SELECT DAY_NUMBER,CONSULTANT_ID,EVENT_ID,EVENT_NUMBER,SESSION_NUMBER,HOURS_UNPAID,HOURS_PAID,PAPERWORK FROM (EVENT_ASSIGNED_CONSULTANT) WHERE (CONSULTANT_ID=:1)
    What should I do now?????? Please remove the brackets () from the table name.
    Instead of (EVENT_ASSIGNED_CONSULTANT) use
    EVENT_ASSIGNED_CONSULTANT

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

  • Forms Data-Block based on stored procedures - REF CURSOR feature NOT FUNCTIONING

    This topic is related to another topic in this forum titled "FORMS HOW TO SET QUERY SOURCE ARGUMENTS??" I posted my message there as well. I am posting as a NEW TOPIC so that it catches the attention of Oracle Support.
    I built a data form based on a stored procedure and REF CURSOR IN OUT parameter.
    My procedure takes a IN parameter to fill in the criteria for the OPEN <cursor_variable> select ... where ... statement.
    In the Value setting of the Query source Arguments , I set the VALUE to ":BLOCK_NAME.ITEM_NAME" at design time to supply the input value to the procedure. this works to the extent of making available the form item value to the stored procedure parameter. I verified this by doing an insert into some debug table , of the incoming parameter value inside my stored procedure.
    The cursor gets opened properly into the REF cursor variable. I verified this by fetching a record into a local variable and inserting the value into a debug table again in the stored procedure.
    (I took care to close and re-open the REF cursor variable again - so that the front-end can continue to fetch it from the first record. )
    ***** PROBLEM **************
    But the front end forms runtime is giving me a FRM-40301 - query returned no records even though the REF cursor is returned properly opened.
    Did anybody else face the same problem ??
    Please post what you found.
    Thanks,
    Shankaran
    null

    This topic is discussed at length in another thread "How Set Value For Query DataSource Arguments?"
    But I am posting the findings here as well.
    THIS TOPIC IS CLOSED.
    My Bad. The problem Cause : I did not include all columns in the
    cursor rowtype in the Data-block. In the wizard for the data block , I selected ONLY the columns that I needed. But I was doing a Select * from <my_table> in my open cursor <Cursor-Variable> .... The <Cursor Variable>
    itself was declared <my_table>%rowtype
    FIX : The Data Block structure (columns included as items) should match the cursor record Structure. One may or may not
    display all the columns in the LAYOUT though.
    But I don't understand why it gives such a misleading message like FRM-40301 Query retrieved no records. Oracle Team fix it.
    Hope this helps people who face the same problem.
    Thanks,

  • Data Blocks - Different data source for Query  and DML

    Would anyone please tell me if it is possible in a BLOCK to define a stored procedure for queriying and a table for DML operations or vice-versa at the SAME time.
    If possible how do you do it using DATA BLOCK WIZARD? If you select your block to be based on stored procedure then it gives only stored procedure options for Querying and DML operations in next few screens.
    Also, suppose I used a stored procedure defined in a block for insert operations, is it implicitly called by INSERT RECORD function key in default menu? How does it take values from different fields on its own?

    Hi Deepon,
    We get data from both BSIK(open items)and BSAK (cleared items). Obviously if a accounting doc is not cleared it would be in open items and vice versa..
    Go through the help link for more information..
    http://help.sap.com/saphelp_bw33/helpdata/en/90/10e73a86e99c77e10000000a114084/frameset.htm
    Regards
    Manga(Assign points if it helps)
    Message was edited by: Manga

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

  • Query data block

    I am trying to execute a query based on a data block.
    The data block name is B_STR and it has a item (checkbox) named CB_SELECT
    When I run this code, it returns an exception saying that it is an invalid table name.
    Is it possible to execute a query based on a data block? Any sugestions? ;)
    Thanks in advance!
    connection_id := exec_sql.default_connection;
    bisconnected := exec_sql.is_connected;
    IF bisconnected = FALSE THEN
    emessage('No primary connection. Please connect before retrying.');
    RAISE no_connection;
    END IF;
    cursorid := exec_sql.open_cursor(connection_id);
    sqlstr := '';
    sqlstr := select * from xpto where store in (select store from :B_STR where :B_STR.CB_SELECT = 1 )';
    exec_sql.parse(connection_id, cursorid, sqlstr);
    exec_sql.define_column(connection_id, cursorid, 1, myvarchar, 1000);
    nign := exec_sql.EXECUTE(connection_id, cursorid);
    LOOP
    IF (exec_sql.fetch_rows(cursorid) > 0) THEN
    exec_sql.column_value(connection_id, cursorid, 1, myvarchar);
    emessage(myvarchar);
    ELSE
    emessage('no more results');
    EXIT;
    END IF;
    END LOOP;
    exec_sql.close_cursor(connection_id, cursorid);
    exec_sql.close_connection(connection_id);

    What is the requirement?
    If your datablco is a multirecord and you need to evaluate record by record to do something depends on, it is better if you go to that block, use the first_record; to put the current record in the first one and evaluate all of them.
    Abdel Miranda
    Panama

  • 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

Maybe you are looking for

  • Calling a word document on click of a tab

    Hi All,          I need to call a word document which has some layout , on click of a button in bsp and populate some values into it. Where should i define the layout of this word document? In the layout itself ? but that will open in a browser right

  • Change file extension in receiver file adapter

    File to File Scenario Posted: Sep 11, 2006 3:47 PM      Reply      E-mail this post  I am working on a File to File scenario. Source System gives out a file: abc ( with no extension) We need to archive it as: abc.done And we need to send it to a FTP

  • Can't create a book in iPhoto 11 (9.5)

    I am trying to create a new book in iPhoto, but when I select New>Book or Share>Create>Book, it opens the book editor (I guess you call it) with a frozen loading image, and that's it. I can't change from hard cover to softcover or wire bound, or sele

  • Navigate between records, ViewLink problem...

    Hi, all! I will try to explain my problem. If something is not clear the pleas let me know. So, I have two VO: UzglabasanasDati and VidesDati. These VO have related with VL (UzglabasanasDati_VidesDati1) with 1 to 1 relationship. When I open Uzglabasa

  • No more scanning HP LaserJet 3020 after upgrading to MacOS X 10.10 Yosemite

    The device still prints. Scanner device: You can not open the application "HP Scan" because PowerPC applications are no longer supported.  Systemversion: OS X 10.10.1 (14B25)   Kernel-Version: Darwin 14.0.0   Startvolume: Macintosh HD