Cursor in post-query

Hello,
in a post-query trigger i'm populating a non-database text item (with Items displayed=7) with the code
DECLARE
  CURSOR crElev IS
    SELECT name ||' '|| surname
      FROM elevi
     WHERE ID=:vw_angajati_note.id_elev order by nume;
BEGIN
  OPEN crElev;
  FETCh crElev INTO :vw_angajati_note.elev;
  CLOSE crElev;
END;but when executing the query, the non-database item doesn't contain the names ordered.. and i don't know why
is it possible to order in a cursor?
Thanks in advance

where id=:vw_angajati_note.id_elev --here are 7 records, and i fetch each of them in :vw_angajati_note.elev (i fetch the name ||' ' || surname).
yes, i wanna the records being sorted and displayed alphabetically
p.s. the database item is id_elev (so there are just numbers) and the non-database item is elev, where i fetch the names

Similar Messages

  • Post Query Trigger with cursor

    Good afternoon to all of you!
    I need your help. I create a master detail form. I created also a post quey trigger, inside I wrote the code below.
    A cursor looks to another table and returns to the form some values i need!
    declare cursor C1 is select apofaa,startdate,enddate,transport
    from trapofdet
    where trapofdet.apofcode = :trapof.apofcode;
    begin
    open C1;
    loop
    fetch C1 into :TRAPODOSI_NEW_NEW.APOFAA, :TRAPODOSI_NEW_NEW.STARTDATE, :TRAPODOSI_NEW_NEW.ENDDATE, :TRAPODOSI_NEW_NEW.TRANSPORT;
    exit when C1%notfound;
    next_record;
    end loop;
    close C1;
    first_record;
    null;
    end;
    How to solve the a. frm-40737, illegal restricted procedure go block in post-query trigger
    b. It seems tha returns all the records but it appears only the last one.
    Please can anybody help with these?
    Thanks in advance!
    Christos

    Christos,
    The Post-Query trigger will fire once for each record returned to your form therefore you need to write your query to return a single row rather than a multiple rows. Using the Post-Query trigger to fetch additional data into your form can cause your form to be very slow - depending on the number of records returned and how many columns are fetched by your Post-Query cursor as well as how quickly the query executes.
    Is your Post-Query trigger on your Master or Detail block. Are you using the Post-Query trigger to populate your Detail block? Are you using a Block Relationship to coordinate your Master and Detail blocks?
    Also, it is helpful to know which version of Oracle Forms you're using.
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Oracle forms- Number formatting in post query

    I have a column called num_value in a table.
    When the user retrieves the data in post query I need the following formatting
    For WBC if the value entered is 3 I want to show in the forms as 3.0 etc....
    So I have a decode statement
    Cursor C5 is select task_desc,decode(substr(task_desc,1,3),'WBC',to_char(num_value,'fm99.0'),
    'RBC',to_char(num_value,'fm99.90'),
    'HGB',to_char(num_value,'fm99.0'),
    'HCT',to_char(num_value,'fm999.0'),
    'PLT',num_value,num_value) as value,alpha_value
    from qc_task_poch_results A,QC_TASKS B
    where a.task_id = b.task_id
    and a.procedure_id = 1127
    and drive_id = 'DRV5528593'
    Begin
    Open C5;
    Fetch C5 into :qc_task_results_poch.num_value
         ,:qc_task_results_poch.alpha_value;
    Close C5;
    End;
    But I amm not getting the formatting.
    The column in the form is non database .
    When I run in toad, I get the right formatting.
    TASK_DESC|VALUE|ALPHA_VALUE
    WBC count|3.0|
    RBC count|2.33|
    HGB count|6.0|
    HCT Count|17.0|
    PLT count|56|
    Any help is appreciated

    You are formatting your data in your select statement not in Forms. Consequently, any format mask you may have on the Item where the data will be display will reformat your data to match the Item's format mask.
    Do you have the format mask property defined on the Item? What is the data type of the item?
    Craig...

  • Post query giving error

    Declare
    cursor fin_ACNTs IS
    SELECT aCODE,dr,cr,seq
    FROM acnts
    where CCODE = :xH_ccode
    and Tcode = :XH_tCODE
    aND tNO = :xh_Tno
    order by seq;
    total_rows NUMBER;
    the above query will return 2 or 3 rows. for example,
    aCODE DR CR SEq
    P30737 1907.600 .000 B1
    P30737 .000 1907.600 B2
    I have 3 rows wise control fields on my form canvas
    r1c1 r1c2 r1c3 r1c4
    r2c1 r2c2 r2c3 r2c4
    r3c1 r3c2 r3c3 r3c4
    & I want to Store the above query result in Such way that
    the 1st row returned should be saved in r1c1 r1c2 r1c3 r1c4
    and the 2nd row returned in r2c1 r2c2 r2c3 r2c4
    if the query returns 2 rows
    i tried to incorporate it in thiS way, but needs SOme help;
    declare
    cursor fin_ACNTs IS
    SELECT aCODE,dr,cr,seq
    FROM acnts
    where CCODE = :xH_ccode
    and Tcode = :XH_tCODE
    aND tNO = :xh_Tno
    order by seq;
    total_rows NUMBER;
    begin
    FOR i IN fin_ACNTs LOOP
    :ctrl.Rc1 := i.aCODE;
    :ctrl.R[i]C2 := i.dr;
    :ctrl.R[i]C3 := i.cr;
    :ctrl.R[i]C4 := i.seq;
    num_total_rows := fin_ACNTs%ROWCOUNT;
    END LOOP;
    end;
    while compling the trigger am getting the errors;
    Error 49 line 15 column 5
    Bad bind var :ctrl.R
    Error 103 line 15 column 5
    Encountered th symbol "[" when expecting one of the following
    := . ( @ % ; indicator

    TYVM, Mr. Kuba,
    those 4 rows r1c1....did get filled properly. I have now 1 more problem. about this form so,
    I have a columnar tables
    inventotry_header (Inv_head) and
    inventory_detail (Inv_detail)
    in post-database-commit i am saving some details in to a 3rd table, ACNTS
    Inv_head is linked to inv_detail thru primary-foreign key, table ACNTS is independant.
    i have joined inv_head==>ACNTs in forms.
    i wrote this post-query Suggested by you. i want to display ONLY the control fields r1c1.....
    derived from the acnts table in post query and keep acnts table fields hidden.
    the acnts table should just be saved in the background(in post-database-commit) and
    its values will be displayed on form thru the control fields.
    but when i make the visible property of the acnts table fields to "NO", the post query result does not display
    the control fields r1c1.... and on querying, at first record it gives error,
    FRM-40106 No navigable items in destinations block
    and why i dont want to use the acnts tables for display, because i want to assign & display the control fields
    as i enter the details in inv_head and inv_detail, in the sequence of r1c1 r1c2 r1c3 r1c4....
    which i dont think will be possible with acnts tables (which is a linked actual db table).
    hope i have made it clear.

  • POST-QUERY and LOV

    Hi,
    I created a POST-QUERY trigger on a LOV field; I have checked off “Validate from list”, so the user is forced to use the LOV. However every time a user retrieves a record, and then tries to re-query, they get the message, “Do you want to save the changes you have made?” I assume this is because of the POST-QUERY trigger; when I uncheck the “Validate from list” the forms runs correctly. Is there anyway to use the validate from list function, but without the save message?
    Thanks in advance.
    ===POST-QUERY===
    declare
         --Country of Birth
         cursor lookup_cob is select codetext
         from country
         where code = :app.country_birth;
    begin
         --Country of Birth
         open lookup_cob;
         fetch lookup_cob into :app.txtcob;
         close lookup_cob;
         exception
         when no_data_found then
              null;
         when others then
              message(sqlerrm);
    end;

    If I have more than one procedure in my POST-QUERY trigger then I have to insert this code multiple times?
    SET_ITEM_PROPERTY('block_name.item_id1',ITEM_IS_VALID,PROPERTY_TRUE);
    SET_ITEM_PROPERTY('block_name.item_id2',ITEM_IS_VALID,PROPERTY_TRUE);

  • Need Post Query Workaround - HELP!

    This is urgent. Any help will go along way.
    I am using Forms Builder 6i version 6.0.8.13.0.
    I am designing a web based form that has 6 blocks.
    Blocks 1, 3, 5 and 6 are all related via relation objects in the form.
    Block 1 is a key block used as a lookup. Users enter data in this block for which they are looking for related information. It will only contain 1 record, all other blocks are multi-record capable.
    Block 2 populates programatically based on data entered in block 1. It is excluded from the navigation sequence.
    Then upon navigating to block 3 from block 1 the rest of the form/blocks populate with all the related data to the key values entered in block 1.
    Here's my problem.
    I need block 4 to populate for every row returned in block 3. Block 4 is not and can not be related to block 3 via a relation object. I now have it populating programaticlaly based on the click of a button that the user has to press after all data is retrieved or whenever they scroll to a new record in block 3 - not good for the user. What I want to do is have block 4 populate automatically as rows are retreived into block 3. That way as the user scrolls through the data in block 3 the data in block 4 will change to reflect.
    The difficulty is that a post query will not work because in the procedure that populates block 4 I need to use a next_record built-in. Block 4 is not a base table block. It is a mulit-record display block (6 records displayed at a time) with a scroll bar. So in order to programatically populate it I have to fill the first row then move to the next record and fill it and so on and so on.
    I need a work around.
    I need a way to let block 3 be queried for records and as each one comes into the block call the procedure to populate the other block - remember that the procedure uses next_record and post query does not like the restricted built-in. I tried to use when_new_record_instance to call the procedure. This allows the data to be queried and as the user scrolls through the data block 4 populates on each new record. It did not work.
    I realize this problem may be hard to clearly understand from my description so if anybody has the interest in solving a week long problem you can fire away your suggestions or email me at [email protected].
    Maybe I can send you a screen shot to clarify the layout a little better.
    Thank You.

    Brian,
    You can try this method, which will definately work.
    As you have mentioned you want the module to automatically query Block4 based on the information ob Block 3.
    You can write a form procedure which programitically populates BLOCK4. This procedure can be called from the KEY triggers which allows restricted procedures to be used.
    Try this :-
    1) Create Key-Up, Key-Down triggers on Block3.
    Example :-
    Key-Down Trigger On Block 3
    Declare
    lCurrRowPos Varchar2(10);
    Begin
    Next_Record; /* The cursor is on Block 3 */
    lCurrRowPos := :System.Cursor_Record;
    Go_Block ('BLOCK4');
    Clear_Block (No_vALIDATE);
    Execute_Query;
    OR prg_populate_block4l
    First_Record;
    Go_Block ('BLOCK3');
    Go_Record (lCurrRowPos);
    End;
    Key-Up Trigger On Block 3
    Declare
    lCurrRowPos Varchar2(10);
    Begin
    Previous_Record; /* The cursor is on Block 3 */
    lCurrRowPos := :System.Cursor_Record;
    Go_Block ('BLOCK4');
    Clear_Block (No_vALIDATE);
    Execute_Query;
    OR prg_populate_block4l
    First_Record;
    Go_Block ('BLOCK3');
    Go_Record (lCurrRowPos);
    End;
    This way whenever the cursor moves up and down the block3 the information is automatically displayed in BLOCK4.
    Hope this helps.
    Shailender Mehta

  • Populate Form Field from Post-Query Trigger

    I have a form with some fields like "start_date", "company_id", "previous_start_date", "previous_company_id". Out of these, the "previous" fields are unbound and the others are bound to "my_companies" table. All are in the same block on the form. I have a post-query trigger which runs a cursor to select "previous" values based on the "start_date" and "company_id". More than one "previous" values is retrieved each time. My problem is that my cursor writes back only one value into my form field. I ran the cursor as a pl/sql block in TOAD to test and it fetches all the records that I need. I'm not sure what I'm doing wrong in writing the values into form items. The form items are of type "custom" and display type is "text" (I'm creating the form in Oracle Designer). My cursor code is something like this:
    declare
    cursor previous_data_cur is 
            select company_id,start_date
               from my_companies
               where company_id = :myblock.company_id
               and start_date < :myblock.start_date;       
    BEGIN 
        open previous_data_cur;
        LOOP
        fetch previous_data_cur into :myblock.prev_company_id, :myblock.prev_start_date;
        EXIT WHEN previous_data_cur%NOTFOUND;
        END LOOP;
        close previous_data_cur; 
    END; Can anyone provide any pointers on what I could be doing wrong or what I should do to make this work?
    Any help is greatly appreciated.

    Do you have several previous date fields per record?
    How are they named? Previous_date_1, previous_date_2,...?
    Try this:
    declare
    cursor previous_data_cur is 
            select start_date
               from my_companies
               where company_id = :myblock.company_id
               and start_date < :myblock.start_date;
       l_previous_data previous_data_cur%ROWTYPE;       
       l_count NUMBER;
    BEGIN 
       l_count := 1
       FOR l_previous_data IN previous_data_cur
       LOOP
           copy(l_previous_data.start_date, 'my_block.previous_start_date_'|| l_count);
        END LOOP;
    END; Caution:
    - number of retrieved records may not exceed number of previous_date fields.
    - not tested

  • Master-Detail Form - implementing some thing like Post-Query trigger

    Hi all,
    I am struggling to implement an eqivalent of a post-query trigger in Oracle Forms. Please bear with me as I am trying to explain in detail what the problem is.
    Here is my situation.
    I have three tables EMP, DEPT and LOCATION. I created a Master/Table pages on EMP and DEPT.
    Basic relationships.
    Each LOCATION has one or more DEPTs; Each DEPT is at one and only one LOCATION.
    Each DEPT has one ore more EMPs; Each EMP is assigned to only and only DEPT.
    Not getting too complicated, here are the table layouts:
    LOCATION:
    ID number(10,0) not null,
    NAME varchar2(20) not null
    DEPT
    ID number(10,0) not null,
    NAME varchar2(20) not null,
    LOC_ID number (10,0) not null foreign key from LOCATION
    EMP
    ID number(10,0) not null,
    NAME varchar2(20) not null,
    DEPT_ID number (10,0) not null foreign key from DEPT
    Assume I have all the constraints, BIU triggers, sequences defined properly.
    I am using the APEX page wizard to create a Master/Detail Form on DEPT and EMP. The first page is the Master Report on DEPT. I want to display the Location Name on this page also. Because the Master Report allows
    you to change the query, I was able to add the Location Name as part of the
    query. This was very simple.
    Select a.name "Department_Name",
    b.name "Location"
    from dept a, location b
    where a.loc_id = b.id
    Moving on, In the Master Detail Form, I would like to get the Location Name as part of the first Region (Dept Region).
    In this region, I would like to include the Location Name also. So my first region on the Master Detail form includes:
    Dept Id: ________
    Dept Name: _______
    Location Name: __________
    As Region are automatically populated using using a Fetch Row from EMP table (Automated Row Fetch) on an After Header process point, I don't have a way of including the Location as part of query. So I created a Region level Item called Location Name, made it Display only.
    In the old SQL*Forms, or Oracle Forms days, I used to use a Post-Query trigger, or Post-Change trigger to fire on the Loc_Id column to populate the Location Name. Simple fetch like:
    Select name
    into :P80_location_name
    from location
    where loc_id = :P80_loc_id
    However, I am struggling to implement some thing simple like this in APEX. Tried creating a processes, computatations etc, but nothing is working.
    I have seen some previous responses to fetching values from a foreign table
    using a button or AJAX script, but this should be very basic. What am I
    missing here?
    Appreciate any insights.
    Thanks.
    John

    Hi John,
    I'm not too familiar with the post-query triggers in Oracle Forms, but the use of a List of Values (LOV) on your LOCATION table might do the trick for you. If you create a dynamic LOV based on your LOCATIONS table, it can then be referenced by the LOC_ID item on the Master-Detail page, to display the Location Name. You could try doing the following:
    1. Create a new dynamic LOV, LOCATIONS, using a query similar to the following:
    select Name d, ID r
    from LOCATION
    order by 1
    2. Edit the "Create" button on the Master report page, and in the "Optional URL Redirect" section set "Request" to CREATE. Click Apply Changes, to save the setting.
    3. Edit the LOC_ID item on your Master-Detail page, and set the following:
    * in the "Name" region change the "Display As" setting to Select List
    * in the "Label" region change the Label to Location Name.
    * in the "List of Values" region set the "Named LOV" to LOCATIONS
    * in the "Read Only" section, set the condition to Request != Expression 1, and set Expression 1 to CREATE.
    Click Apply Changes to save the settings.
    When you run the pages now, the Location Name field will appear as Read-Only when editing a selected Master row. The item will appear as a Select List when the user clicks "Create" on the Master page, to create a new Master row.
    I hope this helps.
    Regards,
    Hilary

  • Cursor in select query

    how i use cursor in select query ?
    I have 2 table
    1. emp
    2. dept
    i want output like
    Manager
    a
    b
    c
    Clark
    d
    e
    f
    HOD
    g
    h
    i
    by using cursor

    We wouldn't help you to learn something if we just give you an answer.
    Show some effort by yourself first, then ask what specific problem you encountered and you'll find this forum much more willingness to help.

  • OPEN cursor for large query

    OPEN cursor
    When you OPEN a cursor for a mult-row query, is there a straightforward way that you can have it only retrieve a limited number of rows at a time and then automatically delete those rows as you do the FETCH against them? I'm thinking of setting up multiple sequential cursors, and opening and closing them as the rows are processed. But I'm hoping there might be a better way.
    The problem is that I'm running out of TEMPORARY during the OPEN cursor stage.
    The application I am working on needs to work in Standard Edition and Personal Edition versions of Oracle.
    Thank you.

    Thanks - I had read the documentation before, but interpreted it differently.
    What I had read was in:
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#i45288
    The extract of interest was:
    Opening a Cursor
    Opening the cursor executes the query and identifies the result set, which consists of all rows that meet the query search criteria. For cursors declared using the FOR UPDATE clause, the OPEN statement also locks those rows. An example of the OPEN statement follows:
    DECLARE
    CURSOR c1 IS SELECT employee_id, last_name, job_id, salary FROM employees
    WHERE salary > 2000;
    BEGIN
    OPEN C1;
    Rows in the result set are retrieved by the FETCH statement, not when the OPEN statement is executed.
    My interpretation was that the result of the query was put into the temporary tablespace and then retrieved into the program during the FETCH.
    Assuming I was wrong, what I'm wondering now is how I can possibly be running out of temporary space during this OPEN cursor process.

  • LEFT OUTER JOIN, Problem in POST-QUERY TRIGGER

    Hi,
    Please guide for the following
    I wrote below query in POST-QUERY Trigger of a TABULAR DATA BLOCK, having only one text item, called INVENTORY_ITEM
    select c.cat||' '||s.subcat||' '||l1.lvl1 ITEM INTO :DATABLOCK.INVENTORY_ITEM
    from itemcat c
    LEFT OUTER JOIN itemsubcat s on (c.catid = s.catid)
    LEFT OUTER JOIN lvl1 l1 on (s.subcatid = l1.subcatid)
    When I compile the module an error is generated
    *" Encountered the symbol 'LEFT' when expecting one of the following ,; for group having intersect minus order start union where connect ".*
    Above query is working fine in ORACLE SQL DEVELOPER .
    Any solution please.
    Regards,

    Difference

  • How to implement  post-query in bc4j or JClient

    How to implement post-query in bc4j or JClient ?
    Does any one know if I want to select some data from other table after every populate record,
    like someing doing in post-query of Oralce Forms?
    where and how to do this ?

    If yout need post-query for filling descriptive colums (eg. department name in emploees) you should build a view object which includes the descriptive colums by joining the relevent tables

  • POST-QUERY TRIGGER

    Hello.
    I'm a newbie here.
    I'm currently studying Oracle Form Builder and I'm a student.
    I've encountered this problem where I need to create a post-query trigger in a data block that counts a total number of rows in a particular item using a display item.
    I'm know I need to use the INTO clause to populate the display item but I got stuck.
    Please help.
    Thank you very much..

    First of all your code to calculate the total rows returned from a query is wrong.
    Try this one in a Post-Query Trigger
    DECLARE
    total_rows_returned NUMBER;
    BEGIN
    SELECT COUNT(*)
    INTO total_rows_returned
    FROM table_name;
    :block_name.display_item := total_rows_returned;
    END;
    Good Luck
    Saadat Ahmad
    Oracle Developer

  • "FRM:40654 Record has been updated by another user" - Error in POST-QUERY

    Hi,
    I'm using Forms version 6.0.8.26.0
    In one of the forms, its data block is based on a view.
    In POST-QUERY trigger, I try to change the value for a database item. This operation results in following error:
    "FRM-40654: Record has been updated by another user. Re-query to see change."
    After this message the value of the item is automatically being set back to what was queried from the DB.
    I tried setting the DML Returning Value to 'Yes'. It doesn't help :(
    Any suggestions please?
    Thanks,
    Usha

    Hy
    try to set key-locking delayed
    and check
    if one field from the view as primary key
    or
    manually create On-Update, On-Insert, On-Delete and On-Lock triggers
    or
    write an INSTEAD OF TRIGGER

  • Is there an Oracle Forms Post-Query trigger equivalent

    Hi.
    Jdeveloper 11.1.1.2
    Is there a way in ADF to populate extra read-only text-columns in an af:table (based on a ViewObject) as was possible in Oracle Forms with a Post-Query-Trigger:
    Post-Query
    Perform an action after fetching a record, such as looking up values in other tables based on a value in the current record.
    Fires once for each record fetched into the block.
    Best regards
    Erik

    Erik wrote:
    Hi.
    Jdeveloper 11.1.1.2
    Is there a way in ADF to populate extra read-only text-columns in an af:table (based on a ViewObject) as was possible in Oracle Forms with a Post-Query-Trigger:
    Post-Query
    Perform an action after fetching a record, such as looking up values in other tables based on a value in the current record.
    Fires once for each record fetched into the block.
    Best regards
    ErikHi,
    http://docs.oracle.com/cd/E15523_01/web.1111/b31974/appendix_formstriggers.htm#sm0350

Maybe you are looking for

  • Camera settings on Blackberry Q10

    Hello, I recenlty bought a Q10, and have just discovered all the pictures I have recently taken are not on the media card but on the phone only. Having find some instructions on the interenet about to save on media card, I have the following problem:

  • Open default program of a document

    I watched some videos in Adobe MAX and am excited about the new features to be released in AIR 2. AIR 2 will allow a file to be opened by the system default program (e.g. .doc by MS Word), but - to my understanding - AIR 2 doesn't fire an event when

  • BI Query Iview transport

    Hello, I was asked to post the question here. I would like to know how to transport a query iview being used in the portal from Dev to QA and so on.And i mean the IVIEW, not the web template. Please assist Thanks

  • Planning Data how to Update

    Dear All, Through which transaction code do I update  planned figures so that the same may appear business area wise in the undermentioned reports S_ALR_87012253 - Annual Plan/Actual Comparison S_ALR_87012254 - Half-Year Plan/Actual Comparison S_ALR_

  • Business scenario on Discount.

    HI SAP Gurus, I want to configure the settings as folllows: we need to give a special weekend discount for sundays only. Adiscount of Rs.50  to be given whenever the items in the line item gets over Rs. 1000. .i.e suppose in the 6th line item total v