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

Similar Messages

  • NEED SQL QUERY writing help

    oracle 10g.
    os : linux
    table data appears like this
    SQL> select * from test_grp;
    COL1 COL2
    aaa 111
    aaa 444
    aaa 222
    bbb 333
    bbb 555
    SQL> select * from test_grp order by 2;
    COL1 COL2
    aaa 111
    aaa 222
    bbb 333
    aaa 444
    bbb 555
    As per my application requirement I need to seggerage the data as
    follows
    aaa (2) ie --- 111,222
    bbb(1) is --- 333
    aaa(1) is --- 444
    bbb(1) is -- 555
    I am not able to frame this. Any help ?

    SQL> create table test_grp
      2  as
      3  select 'aaa' col1, 111 col2 from dual union all
      4  select 'aaa', 444 from dual union all
      5  select 'aaa', 222 from dual union all
      6  select 'bbb', 333 from dual union all
      7  select 'bbb', 555 from dual
      8  /
    Tabel is aangemaakt.
    SQL> select col1
      2       , col2s
      3    from ( select col1
      4                , rtrim(col2s,',') col2s
      5                , rn
      6                , sumn
      7             from ( select col1
      8                         , col2
      9                         , sum(n) over (order by col2) sumn
    10                      from ( select col1
    11                                  , col2
    12                                  , case when col1 = lag(col1) over (order by col2) then 0 else 1 end n
    13                               from test_grp
    14                           ) t
    15                  )
    16            model
    17                  partition by (sumn)
    18                  dimension by (row_number() over (partition by sumn order by col2) rn)
    19                  measures (col1, cast(col2 as varchar2(100)) col2s)
    20                  rules
    21                  ( col2s[any] order by rn desc = col2s[cv()] || ',' || col2s[cv()+1]
    22                  )
    23         )
    24   where rn = 1
    25   order by sumn
    26  /
    COL COL2S
    aaa 111,222
    bbb 333
    aaa 444
    bbb 555
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • I need sql query please help me out

    I have two databases 1) erp 2) edusource
    In erp database i  have table  master tables and  columns  like RecordId , value type ,Feildtext,description,Meaining,parentid etc
     data stores based on value type like
    1
    Country
    In
    India
    NULL
        NULL
    True
    2
    Country
    Aus
    Austrilia
    NULL
        NULL
    True
    3
    Country
    Usa
    United States of America
    NULL
        NULL
    True
    4
    Country
    Uk
    Great Britian
    NULL
        NULL
    True
    5
    State
    AP
    Andhrapradesh
    NULL
         1
    True
    6
    State
    MH
    Maharastha
    NULL
         1
    True
    7
    State
    TN
    Tamilnadu
    NULL
         1
    True
    8
    State
    Sdy
    Sydney
    NULL
         2
    True
    9
    State
    MEL
    Melbourne
    NULL
    2
    True
    10
    Location
    IN-Hyd
    Hyderabad
    NULL
    1
    True
    11
    Location
    In SEz
    Sez-Hyderabad
    NULL
    1
    True
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    for  country and state we have a relation ship parentid and recordid
    country
    1 Country
    In India
                                       NULL
    NULL 1
    2 Country
    Aus Austrilia
                               NULL
    NULL 1
    3 Country
    Usa United States of America    NULL
    NULL 1
    4 Country
    Uk Great Britian
                    NULL
    NUL          1 
    5 State
    AndhraPradesh Ap
    NULL 1
    1
    6 State
    Maharastha MH
    NULL 1
    1
    7 State
    Tamilnadu        TN
    NULL        1
    1
    8 State
    Sydney            Sdy   NULL
          2 1
    9 State        Melbourne       MEL
    NULL       2
    1
      in edusource  database i have location and columns like countryname,statename,feildtext,descriptiom,isactive
    i need to insert data in edusource
     database of tbl_ maplocation from that that database

    Try this out:
    DECLARE @geog TABLE (ID INT, type VARCHAR(20), Abrev VARCHAR(6), name VARCHAR(30), parentID INT, Active VARCHAR(5))
    INSERT INTO @geog (ID, type, Abrev, name, parentID, Active) VALUES
    (1 , 'Country' ,'In ', 'India ', NULL, 'TRUE'),(2 , 'Country' ,'Aus ', 'Austrilia ', NULL, 'TRUE'),
    (3 , 'Country' ,'Usa ', 'United States of America', NULL, 'TRUE'),(4 , 'Country' ,'Uk ', 'Great Britian ', NULL, 'TRUE'),
    (5 , 'State' ,'AP ', 'Andhrapradesh ', 1 , 'TRUE'),(6 , 'State' ,'MH ', 'Maharastha ', 1 , 'TRUE'),
    (7 , 'State' ,'TN ', 'Tamilnadu ', 1 , 'TRUE'),(8 , 'State' ,'Sdy ', 'Sydney ', 2 , 'TRUE'),
    (9 , 'State' ,'MEL ', 'Melbourne ', 2 , 'TRUE'),(10 , 'Location' ,'IN-Hyd', 'Hyderabad ', 1 , 'TRUE'),
    (11 , 'Location' ,'In SEz', 'Sez-Hyderabad ', 1 , 'TRUE')
    SELECT g1.ID, COALESCE(g2.name,g1.name) AS countryName, g1.name AS stateName, g1.name AS fieldText, CASE WHEN COALESCE(g2.Active,'TRUE') = 'TRUE' AND g1.Active = 'TRUE' THEN 'TRUE' ELSE 'FALSE' END AS Active
    FROM @geog g1
    LEFT OUTER JOIN @geog g2
    ON g1.parentID = g2.ID
    AND g1.type IN ('location','state')
    WHERE g1.Active = 'TRUE'
    AND COALESCE(g2.Active,'TRUE') = 'TRUE'
    I think you may want to further the relationship, and have 10 be the parent for 11, so you can get country, state, location.

  • 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

  • Help needed in Query

    I have one table Prd_mst, I need a query or function where whenever i pass the child_id into query or function i get the Parent_id of that
    example Data is below :-
    P_ID,P_NAME,C_ID
    null,Computer,1
    1,KeyBoard,2
    1,Mouse,3
    1,Mother Board,4
    3,Scroll Mouse,5
    3,Optical Scroll Mouse,6
    3,Fibre Scroll Mouse,7
    2,Multimedia Key Board,8
    2,Cordless Key Board,10
    2,Normal Key Board,9
    4,586 Mother Board,13
    4,386 Mother Board,11
    4,486 Mother Board,12
    4,P1 Mother Board,14
    4,P2 Mother Board,15
    4,P3 Mother Board,16
    4,P4 Mother Board,17
    14,533 Mhtz P1 CPU,19
    14,433 Mhtz P1 CPU,18
    19,533 Mhtz P1 CPU With 100Mhtz BUS,20
    19,533 Mhtz P1 CPU With 133Mhtz BUS,21
    18,433 Mhtz P1 CPU With 100Mhtz BUS,22
    So when ever i put the child id as 22 i should get the 14
    So when ever i put the child id as 21 i should get the 14
    So when ever i put the child id as 9 i should get the 1
    So when ever i put the child id as 15 i should get the 1
    So when ever i put the child id as 5 i should get the 1
    So when ever i put the child id as 3 i should get the null
    So when ever i put the child id as 14 i should get the 1.
    Please help me......
    There is one complex requirement in matrix format.
    Need P_ID , P_NAME , Count( child records)
    P_(nth), P_NAME(nth), Count(child record) nth times.
    Child is again the parent of some child.
    Report is needed for audit purpose.
    Message was edited by: Sandeep Sharma
    Sandeep Sharma

    SQL> CREATE TABLE SANDEEP(P_ID NUMBER,P_NAME VARCHAR2(100),C_ID NUMBER);
    Table created.
    SQL> INSERT INTO SANDEEP VALUES(null,'Computer',1);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(1,'KeyBoard',2);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(1,'Mouse',3);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(1,'Mother Board',4);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(3,'Scroll Mouse',5);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(3,'Optical Scroll Mouse',6);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(3,'Fibre Scroll Mouse',7);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(2,'Multimedia Key Board',8);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(2,'Cordless Key Board',10);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(2,'Normal Key Board',9);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(4,'586 Mother Board',13);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(4,'386 Mother Board',11);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(4,'486 Mother Board',12);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(4,'P1 Mother Board',14);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(4,'P2 Mother Board',15);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(4,'P3 Mother Board',16);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(4,'P4 Mother Board',17);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(14,'533 Mhtz P1 CPU',19);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(14,'433 Mhtz P1 CPU',18);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(19,'533 Mhtz P1 CPU With 100Mhtz BUS',20);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(19,'533 Mhtz P1 CPU With 133Mhtz BUS',21);
    1 row created.
    SQL> INSERT INTO SANDEEP VALUES(18,'433 Mhtz P1 CPU With 100Mhtz BUS',22);
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> set null null
    SQL> SELECT P_ID
      2    FROM SANDEEP
      3     WHERE LEVEL = 2
      4     START WITH C_ID = &1
      5     CONNECT BY C_ID = PRIOR P_ID;
    Enter value for 1: 22
    old   4:    START WITH C_ID = &1
    new   4:    START WITH C_ID = 22
          P_ID
            14
    SQL> /
    Enter value for 1: 21
    old   4:    START WITH C_ID = &1
    new   4:    START WITH C_ID = 21
          P_ID
            14
    SQL> /
    Enter value for 1: 9
    old   4:    START WITH C_ID = &1
    new   4:    START WITH C_ID = 9
          P_ID
             1
    SQL> /
    Enter value for 1: 15
    old   4:    START WITH C_ID = &1
    new   4:    START WITH C_ID = 15
          P_ID
             1
    SQL> /
    Enter value for 1: 5
    old   4:    START WITH C_ID = &1
    new   4:    START WITH C_ID = 5
          P_ID
             1
    SQL> /
    Enter value for 1: 3
    old   4:    START WITH C_ID = &1
    new   4:    START WITH C_ID = 3
          P_ID
    null
    SQL> /
    Enter value for 1: 14
    old   4:    START WITH C_ID = &1
    new   4:    START WITH C_ID = 14
          P_ID
             1
    SQL> SY.

  • Performance issue on query. Help needed.

    This is mainly a performance issue. I hope someone can help me on this.
    Basically I have four tables Master (150000 records), Child1 (100000+ records), Child2 (50 million records !), Child 3 (10000+ records)
    (please pardon the aliases).
    Now every record in master has more than one corresponding record in each of the child tables (one to many).
    Also there may not be any record in any or all of the tables for a particular master record.
    Now, I need to fetch the max of last_updated_date for every master record in each of the 3 child tables and then find the maximum of
    the three last_active_dates obtained from the 3 tables.
    eg: for Master ID 100, I need to query Child1 for all the records of Master ID 100 and get the max last_updated_date.
    Same for the other 2 tables and then get the maximum of these three values.
    (I also need to take care of cases where no record may be found in a child table for a Master ID)
    Writing a procedure that uses cursors that fetches the value from each of the child table hits performance
    badly. And thing is I need to find out the last_updated_date for every Master record (all 150000 of them). It'll probably take days to do this.
    SELECT MAX (C1.LAST_UPDATED_DATE)
    ,MAX (C2.LAST_UPDATED_DATE)
    ,MAX (C3.LAST_UPDATED_DATE)
    FROM CHILD1 C1
    ,CHILD2 C2
    ,CHILD3 C3
    WHERE C1.MASTER_ID = 100
    OR C2.MASTER_ID = 100
    OR C3.MASTER_ID = 100
    I tried the above but I got a temp tablespace error. I don't think the query is good enough at all.
    (The OR clause is to take care of no records in any child table. If there's an AND, then the join and hence select will
    fail even if there is no record in one child table but valid values in the other 2 tables).
    Thanks a lot.
    Edited by: user773489 on Dec 16, 2008 11:49 AM

    Not sure I understand the problem. The max you are getting from the above is already the greatest out of the three - that's why we do the UNION ALL.
    Here's sample code without output, maybe this will clear it up:
    with a as (
    select 10 MASTER_ID, to_date('12/15/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
    select 20 MASTER_ID, to_date('12/01/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
    select 30 MASTER_ID, to_date('12/02/2008', 'MM/DD/YYYY') LAST_DTE from dual
    b as (
    select 10 MASTER_ID, to_date('12/14/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
    select 20 MASTER_ID, to_date('12/02/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
    select 40 MASTER_ID, to_date('11/15/2008', 'MM/DD/YYYY') LAST_DTE from dual
    c as (
    select 10 MASTER_ID, to_date('12/07/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
    select 30 MASTER_ID, to_date('11/29/2008', 'MM/DD/YYYY') LAST_DTE from dual UNION ALL
    select 40 MASTER_ID, to_date('12/13/2008', 'MM/DD/YYYY') LAST_DTE from dual
    select MASTER_ID, MAX(LAST_DTE)
    FROM
    (select MASTER_ID, LAST_DTE from a UNION ALL
    select MASTER_ID, LAST_DTE from b UNION ALL
    select MASTER_ID, LAST_DTE from c)
    group by MASTER_ID;
    MASTER_ID              MAX(LAST_DTE)            
    30                     02-DEC-08                
    40                     13-DEC-08                
    20                     02-DEC-08                
    10                     15-DEC-08                
    4 rows selectedEdited by: tk-7381344 on Dec 16, 2008 12:38 PM

  • Need a query help

    hii
    i need a query help
    i have two tables
    the 1st table will look like this
    associate id weekid no.of. hours
    4000 810 40
    4000 820 30
    4000 830 60
    4000 840 70
    2nd table will look like this
    associate id weekid no.of.hours
    4000 810 40
    4000 820 70
    4000 830 130
    4000 840 200
    so when i subtract the last two records frm each other in the second table the value should be equal to the no.of.hours in the first table.. for example
    the query shud consider the last record and one before the last record and the difference between two records shud be equal to the value in the 1st table
    for example
    consider week id 830 and 840
    in second table 830=130
    840=200
    when u subtraced both values the difference shud be equal to value in the 1st table for tht week id
    1 ---->>>> 840 - 830
    =200 - 130
    =70
    in first table 840 has 70 hrs
    like this it shud check with all records and it shud return only the records which are not equal
    regards
    srikanth

    This..?
    sql>select * from t1;
    A_ID W_ID HRS
    4000  810  40 
    4000  820  30 
    4000  830  60 
    4000  840  70 
    4000  850  80 
    sql>select * from t2;
    A_ID W_ID HRS 
    4000  810  40 
    4000  820  70 
    4000  830  130 
    4000  840  200 
    4000  850  260 
    sql>
    select a_id,w_id,hrs,sum_hrs
    from(
    select t1.a_id a_id,t1.w_id w_id,t1.hrs hrs,t2.hrs sum_hrs,
           t2.hrs - nvl(lag(t2.hrs)  over(order by t1.w_id),0) diff
    from t1,t2
    where t1.w_id = t2.w_id)
    where diff != hrs;
    A_ID W_ID HRS SUM_HRS 
    4000  850  80  260                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Urgent Help Needed Union Query

    Hello All
    I have a complex query (at least i think) which returns result set. Now i want to add to it the records that were not mached by the query i tried
    <Query1>
    Union all
    <Query2> where not in <query1> (hope i am able to express myself)
    but it takes a lot of time
    is there any way that query1 is refered once or i have to redefine the query
    Any Help ??????
    Thanks in advance

    I think i am unable to clearly express myself
    When i try to use outer join error occures end-of-file on communication channel. actualy i have a poorly designed database structure which is not in my control but i am supposed to report on it
    <query1>
    union all
    <Query2> where not in <query1>
    i wanted to say query 1 returns a result set and query 2 reurns rows not selected by query 1
    any workaround

  • I need a query

    Hi
    I've a table with 3(THREE)columns like the following structure:
    desc acc
    Name Null? Type
    MCODE NOT NULL NUMBER(2)
    TYPE CHAR(1)
    BALANCE NUMBER(14,2)
    Select * from acc
    MCODE TYPE BALANCE
    10 I 0
    11 L 0
    12 E 0
    12 L 0
    13 L 0
    14 L 0
    15 L 0
    16 E 154689718
    16 I 11244750
    16 L -11232000
    16 R 234178693
    17 L 0
    18 L 0
    13 rows selected.
    Pls Look at the above query that each ID(MCODE) may 4(four) TYPE ( E,I,L,R) and no more than these But each ID(MCODE) may have TYPE : 1 ( E or I or L or R) ,2 ( E,I or L,R or E,L or I,R ) ,3 (...., ...., ...,or ...,...,...).
    Now I need a query That BALANCE will be group by each MCODE base of clmn TYPE which result will be as follows:
    MCODE BALANCE
    10 ((I) + (R)) - ((E) + abs(L)) Where I= 11244750, R= 234178693
    11 ((I) + (R)) - ((E) + abs(L)) E= 154689718, L= -11232000
    12 ((I) + (R)) - ((E) + abs(L))
    13 ((I) + (R)) - ((E) + abs(L))
    14 ((I) + (R)) - ((E) + abs(L))
    15 ((I) + (R)) - ((E) + abs(L))
    16 ((I) + (R)) - ((E) + abs(L))
    17 ((I) + (R)) - ((E) + abs(L))
    18 ((I) + (R)) - ((E) + abs(L))
    how can it be done in a single oracle query can anyone help me
    Regards
    Alamgir Hossain
    Message was edited by:
    user628107
    Message was edited by:
    user628107
    Message was edited by:
    user628107

    Dear Mr. damorgan
    I respect your previous message. what you mean by honest attempt I don't know. As far we know all are respectable IT professionals in this forum. So we couldn’t expect like that answer from you.
    If you think, that is school work Pls prove yourself. I again post the problem with script specially for your kind attention.
    how can it be done in a single oracle query
    Create table acc(     
    MCODE     NUMBER(2) NOT NULL
    ,TYPE     CHAR(1)
    ,BALANCE     NUMBER(14,2)
    Insert into acc values(11,'L',0);
    Insert into acc values(12,'E',76000);
    Insert into acc values(12,'L',-4500);
    Insert into acc values(13,'L',0);
    Insert into acc values(14,'L',-5000);
    Insert into acc values(15,'L',0);
    Insert into acc values(16,'I',11244750);
    Insert into acc values(16,'E',154689718);
    Insert into acc values(16,'L',-11232000);
    Insert into acc values(16,'R',234178693);
    Insert into acc values(17,'L',0);
    Insert into acc values(18,'L',0);
    Select * from acc
    MCODE TYPE BALANCE
    11 L 0
    12 E 76000
    12 L -4500
    13 L 0
    14 L -5000
    15 L 0
    16 I 11244750
    16 E 154689718
    16 L -11232000
    16 R 234178693
    17 L 0
    18 L 0
    Pls Look at the above query that each ID(MCODE) may 4(four) TYPE ( E,I,L,R) and no more than these But each ID(MCODE) may have atleast TYPE : 1 ( E or I or L or R) OR 2 ( E,I or L,R or E,L or I,R ) OR 3 (...., ...., ...,or ...,...,...).
    Now I need a query That BALANCE will be group by each MCODE base of clmn TYPE which query result will be as follows :
    ( balance = ((I) + (R)) - ((E) + abs(L)))
    Where I= 11244750, R= 234178693
    E= 154689718, L= -11232000
    MCODE BALANCE
    10           0
    11          0
    12          -80500
    13          0
    14          -5000
    15          0      
    16          79501725
    17          0
    18      0
    how can it be done in a single oracle query

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

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

  • 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 giving messages

    Hi all i need help
    I have a database block and in that i an a non database item which i am using it for display purpose and i am getting the for the non database item thru the post query.
    After i retreive my block status is changing and when i immediately press save button without changing any records its giving me 2 records saved message.
    how can i supress this?
    BEGIN
    SELECT DISTINCT W_VLV_FNCT_CD INTO :WVG.W_VLV_FNCT_CD FROM WH_VALVES WHERE
         W_VLV_NUM = :WVG.W_VLV_NUM;
    EXCEPTION WHEN OTHERS THEN
         NULL;
    END;
    /*SET_RECORD_PROPERTY :system.TRIGGER_Record,'WVG','STATUS','QUERY_STATUS');*/
    :WVG.W_VLV_FNCT_CD COLUMN IS A NON DATABASE ITEM.
    Thanks
    -Samsam

    Hi,
    Do two things First check that when ur form opens no field in ur form is getting value from anywhere. May be through parameters or through when new form instance.
    Second Do not use exception When others use exception
    when no record found. Try these things. hoping that first point will solve ur problem.

  • Query Rport Help

    I am trying to program a report to query a list of customers and ytd charter dates for cusomters whose ytd charter cost is greater than the avg ytd charter cost of all customers. This is what I have written:
    [ACCEPT fiscal_year char PROMPT 'Enter the four digit year:'
    SELECT c.cus_lname||''||c.cus_fname,
           ch.char_trip,
           RTRIM(TO_CHAR((ch.char_DISTANCE*MO.MOD_CHG_MILE)*1.35,'$99,999.99'))
    FROM charter.customer c JOIN
         charter.charter ch
         ON c.cus_code = ch.cus_code
         JOIN charter.aircraft a
         ON ch.ac_number = a.ac_number
         JOIN charter.model mo
         ON a.mod_code = mo.mod_code
    GROUP BY c.cus_lname||''||c.cus_fname,ch.char_trip,
    WHERE
             ch.char_date = ADD_MONTHS(TO_DATE(CONCAT('10-01','&fiscal_year'),'mm-dd-yyyy'), -12) AND
    where ch.char_distance >
    (select avg(RTRIM(TO_CHAR((ch.char_DISTANCE*MO.MOD_CHG_MILE)*1.35,'$99,999.99'))))
    from charter.charter ch
    where RTRIM(TO_CHAR((ch.char_DISTANCE*MO.MOD_CHG_MILE)*1.35,'$99,999.99')) = avg(RT\
    RIM(TO_CHAR((ch.char_DISTANCE*MO.MOD_CHG_MILE)*1.35,'$99,999.99'))))
    Tables include:
    charter: char_trip{pk}, char-date,ac_number{fk2},destination,char_distance,cus_code{fk1}
    customer:cus_code{pk}, cus_fname, cus_lname,cus_address
    aircraft: ac_number{pk}, mod_code{fk1}
    Model: mod_code{pk}, mod_chg_mile
    Total miles are calculated by ((distance * mod_chg_mile)*1.35)
    When I run this I get the following:
    old 13: ch.char_date = ADD_MONTHS(TO_DATE(CONCAT('10-01','&fiscal_year'),'mm-dd-yyyy'), -12) AND
    new 13: ch.char_date = ADD_MONTHS(TO_DATE(CONCAT('10-01','2008'),'mm-dd-yyyy'), -12) AND
    WHERE
    ERROR at line 12:
    ORA-00936: missing expression
    Unsure what to do, Ihave tried many variations to correct but only get other errors. I cannot seem to get it correct.
    Thanks in advance..
    Barb

    Hi, Barb,
    You should develop code in very small steps. For example, make sure you can get the right data for all customers, then refine that query so it only includes csutomers with above-average costs. If you do that, you'll be able to find more errors yourself and, if you need to ask for help, it will be clearer what your problem is.
    The query you posted has lots of errors:
    (1) What is the formatted number you're displaying? You're doing a GROUP BY query, so it's probably the result of some group function (like SUM or AVG).
    (2) You can't put a comma at the end of the GROUP BY clause
    (3) GROUP BY comes after WHERE
    (4) In the TO_DATE statement, there is one hyphen in the first argument, but two hyphens in the second. (This is not really an error, but you don't need CONCAT: see below.)
    (5) AVG requires a number argument. You can't use a formatted string (with $ and ,). Use the actual numbers (such as ch.char_distance*mo.mod_chg_mile*1.35 is a number).
    (6) There are lots of mistakes involving parentheses in the subquery. Use newlines and tabs to make matching parentheses line up.
    So write a query that displays all the information you want for all customers. (The query below is my best guess.)
    When you have that much working, post another question like this:
    Subject: Showing Above-Average Rows Only
    I have this query ...
    it produces these results ...
    I want to show only the rows where ytd_charter_cost is above average for the result set.
    That is, instead of all the rows above I want only these rows ...
    -- Query for all customers
    -- Numbers (1), (2), ... in comments refer to points listed above
    SELECT     c.cus_lname||''||c.cus_fname,
         ch.char_trip,
         RTRIM     ( TO_CHAR     ( SUM ((ch.char_DISTANCE * MO.MOD_CHG_MILE) * 1.35)     -- (1)
                        , '$99,999.99'
                        )                                   -- (6)
    FROM     charter.customer     c
    JOIN     charter.charter          ch
    ON     c.cus_code = ch.cus_code
    JOIN     charter.aircraft     a
    ON     ch.ac_number = a.ac_number
    JOIN     charter.model          mo
    ON     a.mod_code = mo.mod_code
    WHERE     ch.char_date = ADD_MONTHS     ( TO_DATE     ( '10-01-&fiscal_year'          -- (4)
                                       , 'mm-dd-yyyy'
                             , -12
    GROUP BY     c.cus_lname||''||c.cus_fname,ch.char_trip;                    -- (3)

Maybe you are looking for