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.

Similar Messages

  • Query based on a non-database item in master/detail block

    Hi,
    I have a master/detail block, and in the master the block in have non database control item which displays the user name. Now i would want to retrive all the master/detail records based on the control item. Is that possible? How can i do it?
    Any help would be appriciated.
    Thanks
    Kavitha

    use the set_block_property (default_where) and the execute_query built-ins. more info in the online help

  • Searching master block based on value in detail block

    I have two blocks on a form. A master block for purchase orders and a detail block for the line items. I need to provide users with the ability to search the purchase orders based on the values entered into the detail block (line items), during the query entry. I am considering to check to see which block the cursor resides by using the :SYSTEM.CURSOR_BLOCK variable, then retrieving the value from the current item and running a query, using that query. The problem is that I am not very familiar with Forms and do not know how to implement my idea. Any ideas?
    null

    I copied you an example from metalink. Hope it will help.
    Doc ID:
    Note:109583.1
    Subject:
    How to query a Master record from a Detail Block
    Type:
    BULLETIN
    Status:
    REVIEWED
    Content Type:
    TEXT/PLAIN
    Creation Date:
    22-MAY-2000
    Last Revision Date:
    03-AUG-2001
    PURPOSE
    ------- To query a master record from a detail record. DESCRIPTION
    =========== The user would like to enter a query criteria in the detail block
    and then query the master record based on the above user input. SOLUTION
    ======== Create the master and detail blocks and the relationship in the usual
    manner. We will consider here the blocks DEPT and EMP based on the
    SCOTT schema. 1. Create a KEY-ENTQRY trigger at the block level of the detail block
    (EMP) and add the following code in it : GO_BLOCK('dept');
    CLEAR_BLOCK(no_commit);
    GO_BLOCK('emp');
    ENTER_QUERY; 2. Create a KEY-EXEQRY trigger for the detail block and add
    this : EXECUTE_QUERY;
    :global.deptno := :emp.deptno;
    :global.flag := 'T';
    GO_BLOCK('dept'); This will store the value of the deptno (primary key) in a global variable
    :global.deptno and set another global variable :global.flag to 'T'. This
    will be explained as we progress. 3. Create a WHEN-NEW-RECORD-INSTANCE trigger for the detail block
    and add the following : -- This is used to populate the MASTER block with the corresponding
    -- record whenever the user navigates through all the records in the
    -- DETAIL block if get_record_property(:system.cursor_record,:system.cursor_block,status) = 'QUERY' then
    SELECT rowid,deptno,dname,loc
    INTO :dept.rowid,:dept.deptno,:dept.dname,:dept.loc
    FROM dept
    WHERE deptno = :emp.deptno; -- This is to set the status of the record populated
    -- to QUERY and not to create a new record SET_RECORD_PROPERTY(1,'dept',status,QUERY_STATUS);
    end if; 4. Create a WHEN-NEW-BLOCK-INSTANCE trigger for the master block again
    and add this : if :global.flag = 'T' then -- set the variable to a different value
    :global.flag := 'F';
    :dept.deptno := :global.deptno; -- This will query the master table for the record based on the
    -- deptno of the detail table which is stored in :global.deptno -- For ex: if an employee of department 10 has been queried in
    -- the detail, then the global.deptno will have the value 10,
    -- which is used in the query below to fetch the master record. SELECT rowid,deptno,dname,loc
    INTO :dept.rowid,:dept.deptno,:dept.dname,:dept.loc
    FROM dept
    WHERE deptno = :global.deptno;
    set_record_property(:system.cursor_record,'dept',status,QUERY_STATUS);
    GO_BLOCK('emp'); end if; EXPLANATION
    =========== Actually in the above method we are using the base table blocks as a
    non-base table block when we query the master from detail. We are
    displaying the master record fetched from the table based on
    the query supplied in the detail. So after the fetch, if we clear the
    block or form then we get a "Do you want to save the changes you have made"
    alert. So in order to supress this while entering a normal master-detail
    query, we have created the global variable, :global.flag. There is a limitation though, if you query detail records and then
    navigate to the master block and then press the down arrow( i.e.,
    navigate to the next record) and then presses the up arrow to
    navigate back to the same record, then the detail records that
    were originally populated will change and a new set of records will
    get displayed. This is because the normal master-detail query is
    taking place during MASTER record navigation. This can be controlled by creating a flag (global variable) and setting
    its value and thus preventing the user from navigating to the next master
    record. Do the following : 1) In the KEY-EXEQRY trigger of the detail add the following :global.control_master := 1; 2) Create a KEY-EXEQRY for the master and add this : :global.control_master := 0;
    EXECUTE_QUERY; 3) Create a KEY-DOWN in the master with the following in it: IF :global.control_master <> 1 THEN
    down;
    END IF; Declare all the global variables before running the Form. RELATED DOCUMENTS
    Note:611.1

  • Populating called block based on criteria from previous block

    i have a form where the query is based on the zipcode provided. I have a button within block a that calls another block b to display all records with that particular zipcode. I want the display on block b to show only the records for the specified zipcode. Please help and tell me how do I make this happen?

    - In the WHERE-Clause-property of block b enter :
    :BLOCK_A.ZIP_CODE
    - Put a button next to Zip-Code of Block a
    in the WHEN-BUTTON-PRESSED trigger enter :
    GO_BLOCK('BLOCK B');
    EXECUTE_QUERY;
    Another option would be to use a relation between both blocks ...

  • Date query in non database block

    Hi Experts
    I am doing query in a database via a non data base block.The field in which i want to query is join(DD-MON-YYYY hh24:MI:SS) and my non database block is join.
    I want that i shall give the date in the join field like DD-MON-YYYY format and the related datafrom the database will come out.
    So In the KEY-EXEQRY i have written
    IF :system.mode = 'ENTER-QUERY' THEN
    IF :EMP.JOIN_DATE is not null then
    TRUNC(:EMP.JOIN_DATE):=to_date(:EMP.JOIN,'DD-MON-YYYY');
    END IF;
    END IF;
    EXECUTE_QUERY;
    It is showing compilation error.
    The construct is not allowed as the origin of an assignment
    Can you please tell me what is wrong with it.
    detail of join is -
    data type -char
    Regards
    Rajat

    To restrict a query to something based on a non-database-block you need a different approach:
    1. Do nothing in the KEX-EXEQRY-trigger
    2. Create a PRE-QUERY-trigger with the following logic:
    IF :CTRL.JOIN_DATE is not null then
      SET_BLOCK_PROPERTY('EMP', ONETIME_WHERE, 'TRUNC(JOIN_DATE)=TRUNC(:CTRL.JOIN_DATE)');
    END IF;I assumed the following:
    - CTRL is the name of your non-database-block and EMP is your database-block
    - There is an item JOIN_DATE of datatype DATE in your CTRL-block
    - There is a database-column named JOIN_DATE in yourt EMP-table.
    - You are using Forms 10g, if not use DEFAULT_WHERE instead of ONETIME_WHERE
    If one of these is not TRUE, adjust the code i provided to match your object-names.

  • How to display records from a query into non-database field

    Hi
    I a have a problem:
    I have a query with many tables and 6 column(select a,b,c,d,e,f from x,y,z,t,s,g where conditions) and I use 3 parameters.
    I create 3 parameters :datai,:dataf and :partener and a button with a trigger when button is pressed.
    Then a create a manualy block with six field non-database a1,b1,c1,d1,e1,f1.
    Now I want to display all the records from my query into a1,b1,c1,d1,e1,f1 where a1=a,b1=b,etc. and all the records (if I have 20 record, it will display 20 records in non-database field) when I press the button.
    How I made:
    I create a cursor with query then
    begin open cursor
    loop
    fetch cursor into :a1,:b1,:c1,:d1,:e1,:f1;
    end loop;
    close cursor;
    end;
    It display one record in a1,b1,c1 only and it have to display 100 records and are date for all the fields.
    Can somebody help me in this problem?
    Thanks.
    Edited by: 928437 on Oct 1, 2012 2:55 AM

    Creating a view, and querying that into a database block is an excellent solution.
    To use the non-database block:
    You're missing the all-important Next_Record; command.
    <pre> Begin
    Go_block('X'); -- block X is the non-database block
    Clear_Block(No_Validate);
    open cursor X1;
    loop
    If :System.Record_status != 'NEW' then
    Next_Record;
    End if;
    fetch X1 into :a1,:b1,:c1,:d1,:e1,:f1;
    Exit when X1%NOTFOUND;
    end loop;
    close X1;
    end;</pre>

  • SD non credit block

    our delivery document was blocked, how will I know it is blocked by credit or non-credit block, if it is non credit block, how to release the block? if it is credit block(FSCM credit management), it is based on ship to party or sold to party?

    Dear  join
    Before asking Basic questions please look into Google
    Coming to your point we can find Blocked Delivery documents due to credit limit In VKM5
    And you can release in VKM4
    But some times some users will block the customers in XD05 For not creating Delivery's
    so in this case we are unable to trace the customers which customers to  which Delivery documents  are blocked   .. not possible but we can use SQVI Report
    check this link ...Lakshimpathi sir post Delivery Block
    V.14 Sales order blocked
    VA14L Delivery blocked
    let me know for further help
    Thanks a lot
    venu

  • Problem in Execute query on non-database block and database block together

    Hi All,
    In my form,i have
    1. First block is Non-database block with one non-database item.
    2. Second and third blocks are database blocks.
    Now the problem is that i want to perform execute-query for all the blocks.
    If the cursor is on the non-database item of 1st block and i clicks on the "Enter-query" then i am getting message " This function can not be performed here".
    If i click on the item of the database block and then clicks on the "Enter-query" and then "execute-query" it's working fine.
    But i don't want to do in this way.
    My cursor will be on the First block only and then it should perform execute-query.
    I am using this non-database item to copy value of this item to the item of the database block item.
    I think i make you understand about my problem.
    I am using forms 10g on Window xp.
    Please help me.

    Hi!
    Simply create a enter-query trigger on the non-database-block:
    begin
    go_block ( 'database_block' );
    enter_query;
    end;If your search criteria is in the non-database-item in the first block,
    you actually do not need the enter_query build-in.
    Just create a execute-query trigger on the first block like:
    begin
    go_block ( 'database_block' );
    execute_query;
    go_item ( :System.trigger_item );
    end;And in a pre-query trigger on the database-block copy the
    value of your seach item into the item you want to search for.
    Regards

  • Execute query with non database block

    How to execute query with non database block when new form instance trigger.

    Hi Kame,
    Execute_Query not work with non database block. To do this Make a cursor and then assign values to non database block's items programmatically, see following example,
    DECLARE
    BEGIN
         FOR i IN (SELECT col1, col2 FROM Table) LOOP
                :block.item1 := i.col1;
                :block.item2 := i.col2;
                NEXT_RECORD;
         END LOOP;
    END;
    Please mark if it help you or correct
    Regards,
    Danish

  • Forms - query into non database Block

    This is the data in the table. I am querying into a non database block.Have two lines of data
    1. 1062|Sanitation and Cleaning|N|1025
    2. 1063|Eyewash|N|1025
    go_block('qc_procedures');
    first_record;
    loop
    Open C3;
    Fetch C3 into :qc_procedures.procedure_id,
    :qc_procedures.procedure_desc,
    :qc_procedures.optional,
    :qc_procedures.procedure_type_id;
    Exit when :system.last_record = 'TRUE';
    next_record;
    Close C3;
    End loop;
    I am only able to get the first line of data

    I'm not quite sure if i understand your problem.
    First, you didn't post the definition of your cursor C3.
    Second, if you want to populate the block using the cursor, you should loop over the cursor and not over the block, something like
    Open C3;
    first_record;
    loop
      Fetch C3 into :qc_procedures.procedure_id,
      :qc_procedures.procedure_desc,
      :qc_procedures.optional,
      :qc_procedures.procedure_type_id;
      Exit when C3%NOTFOUND;
      next_record;
    Close C3;Third, it would be much easier to base your block on a table or on your query (using FROM-clause-query), then there would be no need for any code.

  • Non-Database Item Sort Using Multiple Block Values

    I need to sort the result set of a block based on a calculated item. I found several messages addressing this, however they all speak to using the columns from within the same block as input variables to the function used to calculate the non-database column value.
    My problem is that I need to use values from a different block as input variables. I have not found a way to use them since I need to use the full block.column syntax. Forms does not like this and always thows an error right at the period(.). I need to do this because the column names are the same in each block. the function compares the column values and changes the record instance background a different color based based on how many of the column pairs match. Each block is mutually exclusive from each other and doing a accurate join is not really possible.
    I tried renaming the block column name to something unique, however I get a variable not bound error when I try to use it in the order by function even though their values are in the top most block.
    For Example:
    First Block. Contains a list of cases that need to be worked because the automated process could not find a valid provider based on the values received. This list is created by a background process.
    Table: CASE_MAIN
    TIN
    CASE_ID
    FCLTY_CM
    MEDICARE_CM
    Unrelated Second Block (i.e., no join). It uses the TIN value in the first block to get a list of all of the providers for the TIN associated with the Case so that a person can assign the correct Provider to the case (A TIN has a provider and address associated with it). As a result there is no link to the results of this table and the CASE_ID. That's what the users needs to do manually
    Table: PROVIDER_MAIN
    FCLTY
    MEDICARE
    I need to take the values in the first block and compare them in the second block so that I can recolor the background based on matching logic in the function below.
    order by clause = get_vals( ''||:FCLTY_CM||''
    ,''||:MEDICARE_CM||''
    ,fclty
    ,medicare) desc
    I am able to do the coloring within the form easily, however I need to order them by how many values match exactly so the ones that match to most value pairs show at the top. Hence ordering by the result of the function. I return a 0,1, or 2 based on the matches. 0 for none and 2 for both.
    I cannot create a view because the sources of the information I need to compare are NOT related to each other, yet. that is what the application is designed to do. I have a case without a
    provider assigned, but I have a tax id number that possible identifies the provider. I use this TIN to query the provider table for all of the possible providers under that TIN. As a result there is no link between the case information and provider information. The goal is to get this list compare the values from the target information and put the most likely matches on top, with
    the ones with the most matches first. I can create a function many ways that takes in various parameters. For example Case ID and Provider Id and query the records in subselects
    individually like so;
    select count(*)
    from (select fclty, medicare from case_main where case_id p_case_id) cm
    ,(select fclty, medicare from provider_main where prv_id = p_prv_id) pm
    where cm.fclty = pm.fclty
    and cm.medicare = pm.medicare
    If the number is greater than zero I know I have a match with that provider and I can sort accoringly. I can also pass in the target information from case_main and the provider inforation from provider_main and then do an if/then statement for comparing. Then I can use this function to create a column value for each record and then use the same reference to the function in the order by clause to order by that value.
    The problem comes in trying to reference the case_id or target information from a different block than where the fucntion needs to be used. I get a variable bound not error message. What am I missing here. Why can I not reference a uniquely named block item as a input variable to a function in a different block? Does Forms first figure out what it needs to retrieve and then executes the SQL for each block in isolation, or does the first block's result set get retrieved, then the second, third, etc. Based on the message i am getting I would suspect the former since it appears their is no value in subsequent blocks. If so is there anyway around this? thanks.

    Don't quite understand your problem completely. But this might help. I sure hope your Provider_Main is a single-record block ...otherwise, how would you supply a list of values of FCLTY and MEDICARE to the function that does the sorting? Be awere, too, that the order-by is processed by the server, and NOT by Forms.
    Assuming it is a single-record block, you can put the values into parameters:
    :Parameter.Fclty := :Provider_Main.Fclty;
    :Parameter.Medicare := :Provider.Medicare;
    Execute_Query;
    And your order-by clause would be
    get_vals( ''||:FCLTY_CM||'',''||:MEDICARE_CM||'',
    :Parameter.Fclty,
    :Parameter.Medicare) desc
    By the way, the first line of your order-by looks strange. Shouldn't it be:
    get_vals( FCLTY_CM || ',' || MEDICARE_CM,
    or even better, get_vals should take in 4 parameters:
    get_vals(Fclty_cm, Medicare_cm, :parameter.Fclty, :parameter.Medicare)

  • How to include non database item in the query

    Hi
    I have a Master-Detail form. where in the detail block one of the field is text item 'X' attached the list of values(Y). Master block includes non database items which is based in the decoding result of the database items for example:
    Gender(Male, Female)>> non database item
    Gender_id(M,F)>>database item
    the form is created based on the template.fmb form for apps. When I run the form in the query mode, i can query about any database item while including query about others non database item does not affect.
    how to can i modify it so this could be handled??
    I know that one way to avoid this issue is to create a view with all my desired field.
    but there should be away to override the build in query used by oracle apps...
    any one has a link, source, document... etc that help on this??
    any idea how to do it without creating a view??
    thnx alot

    Hi HST,
    You can code the handling in POST-Query of the corresponding block to retrive the corresponding data depending on the Queried data.
    Regards,
    Kiran

  • How to query on non database item?

    I am working on AP Invoice form. The Invoice Header block based on table ap_invoices_all, I have database items such as invoice_num, invoice_date, and invoice_amount. I also have some non databases item like supplier and supplier number. I added POST_QUERY:
    declare
    supplier varchar2(240);
    supplier_number varchar2(30);
    supplier_site varchar2(15);
    begin
    select aps.vendor_name, aps.segment1
    into :invoice_header.supplier, :invoice_header.supplier_number
    from ap_suppliers aps
    where aps.vendor_id = :invoice_header.vendor_id;
    Also in PRE-QUERY
    declare
    supplier varchar2(240);
    supplier_number varchar2(30);
    supplier_site varchar2(15);
    invoice_num varchar2(50);
    invoice_date date;
    invoice_amount number;
    begin
    select aia.invoice_num, aia.invoice_date, aia.invoice_amount
    into :invoice_header.invoice_num, :invoice_header.invoice_date, :invoice_header.invoice_amount
    from ap_invoices_all aia
    where aia.vendor_id = (select vendor_id from ap_suppliers where vendor_name = :invoice_header.supplier);
    It's showing fine with Suppier iformation I query by invoices, but I doesn't work when I query by supplier.
    Can anyone help? I really appreciate.

    Hello,
    Thanks for your reply. I think I need to clarify my problem
    Your cursor has the same result as what I have in the post-query:
    Select aps.vendor_name, aps.segment1
    into :invoice_header.supplier, :invoice_header.supplier_number
    from ap_suppliers aps
    where aps.vendor_id = :invoice_header.vendor_id;
    and they both work when I query on a database item, such as invoice_num and the non database item vendor name and vendor number will show up. I am doing ok with this.
    My problem is when I query on vendor name field which is not a database item, such as CLARK PUBLIC UTILITIES, it will not return CLARK PUBLIC UTILITIES only, instead it returned all the suppliers. Could you please help with this? Thanks a lot.

  • Enter_query for non-database block

    Hi there,
    I have a non-database block. When I click on enter query button from toolbar, i get"this function cannot be performed here' error. I want to bring up records based on certain math calculations. I was planning to write a pre-query trigger and add those to pre-query trigger. Will it work since it is a non-database block? Or should i create a button on form to get records populated?
    Thanks

    You won't be able to use the Query-Process-triggers PRE-QUERY and POST-QUERY on a non-database-block.
    But... If you want to "simulate" the behaviour of querying, you can use the KEY-EXEQRY-trigger and put your logic there. This should also work with the standard forms-menus. To supress the error-message on entering query-mode you should additionally write as KEY-ENTQRY-trigger with code NULL;

  • Relation between non-database data blocks?

    Hi all,
    I'm using Oracle Forms Builder 10GR2. I have two data blocks and i want to create a relation between them. They aren't database blocks and when i tried to create a relation between them based on a join condition/joining 2 display items/ i received the error :
    FRM-15004: Error while parsing join condition.Any ideas?
    Thanks in advance,
    Bahchevanov.

    Andreas Weiden wrote:
    As far as i know you cannot create relationships between non-db-blocks (or maybe you can create them, but they will not work).Hi
    Oh yes u can for query purposes only e.g. suppose i have dept table and emp table created Master Block as non-db dept_no & Dept_name and a Detail_block with emp tabel and a dept_no as a foreign key ...
    1. we either set up a form relation ship between the two blocks - if we want the user to retrieve data only -
    2. or we use copy value property in the dept_no item in the detail block to get the copied value from the dept_no of the master to the dept_no of the detail
    3.While the user entered or select the dept_no in the Master Block then Press Entered here comes the role of the WHEN-BLOCK-INSTANCE Trigger
    GO_BLOCK('DEATIL_BLOCK_NAME');
    EXECUTE_QUERY;Here the data will be displayed in the detail block accordingly ...
    So the relation here played the role of the Where Statment or the default where to filter the displaing of data in the Detail Block according to the Master Block
    Regards,
    Amatu Allah.

Maybe you are looking for

  • MOTU 828 mk ll not being recognized by Windows XP in Bootcamp

    Hi All, I have been pulling my hair out over this - and believe me I don't have much to spare! I cannot seem to get Windows to see my MOTU 828 mk ll audio interface. I have Boot Camp installed with Windows XP service pack 2, updated to service pack 3

  • JSF 1.1 integration with shale-tiles-1.0.4 giving page cannot be displayed

    I am trying to get shale-tiles-1.0.4 work with JSF 1.1 I am getting the page can not be displayed error. The page cannot be displayed There is a problem with the page you are trying to reach and it cannot be displayed. Please try the following: Open

  • How to change hexadecima​l

    Hello All, Question: How to change the HEX ? Please see the problem below. 2f287 -> d0d78 Thanks Solved! Go to Solution.

  • Partitions(Maybe EFI) is damaged, MBA can't boot up, how can I restore it?

    Hello all, my MBA is the 3,2 with 256GB SSD and 4GB RAM. I have dual-boot systems(Mac and Ubuntu) through rEFIt. Today I try to dd an USB image to one of the Linux partition. I don't know if I entered the wrong partition number, after reboot, everyth

  • Nikon Jpeg decoding problem.

    Jpeg files saved with the ICC profile "Nikon sRGB 4.0.0.3001" by Nikon PictureProject do not load properly using Java ImageIO.read(). The image is far too dark, but the colors are not swapped. This appears to be similar to the problems reported in bu