Make selection state to tableSelectMany

hi everyone
I have a problem and i would like to someone help me to solve this problem
the problem is :
I use adf 10 components in my jsf pages
one of the pages has <af:table>.... etc
and in this table there <f:facet name="selection"><af:tableSelectMany/></f:facet>
everything is ok about readins the selected rows and .....etc
but the problem is when I want to view this table with old selected rows
I could not find way to build or make selection state
in short I want way to view table with selected and unselected rows depends on my data
thanks

thanks for your replay
the tableSelectMany put the id's of rows that selected in selectionState and exactly in keySet
I tested to do this code when show the page
TableBinding.setSelectionState(new RowKeySet());
TableBinding().getSelectionState().getKeySet().add(new String("1"));
and 1 is id of one of the rows but not selected
can you help me by example please

Similar Messages

  • How to make select statement wait

    how can i make the select statement wait until there is not lock on the table( or a row) and return the row once the lock is released is there is a lock on it
    example
    i have a Table t1 with columns c1 and c2
    process1
    stmt1 as select c1 from t1 where c1=1
    process2
    select c1 from t1 where c1=1
    /*some operations */
    update t1 set c2=4 where c1=1
    when process1 is executed it has to wait for process 2 to complete the return a row since it has to be synchronised and are run from different location
    thanks in advance

    You want to get around session consistent select. This is such a nice feature actually. But if you really want to do it, you can fool process 1 by telling it you want to do an update.
    This is process 2:
    SQL> update emp set sal=900 where empno=7369;
    1 row updated.Note I do not commit yet.
    This is process 1, with a "select for update".
    SQL> select sal from emp where  empno=7369 for update wait 10;
    select sal from emp where  empno=7369 for update wait 10
    ERROR at line 1:
    ORA-30006: resource busy; acquire with WAIT timeout expired"wait 10" tells Oracle to wait 10 seconds to get a lock.
    Now process 2 commits within the 10 seconds. The result of process 1 is then:
    SQL> select sal from emp where  empno=7369 for update wait 10;
           SAL
           900
    SQL> commit;You have to issue a commit or rollback in process 1 immediately to release the lock that process 1 laid on the record.

  • How to use bind variable in this select statement

    Hi,
    I have created this procedure where table name and fieldname is variable as they vary, therefore i passed them as parameter. This procedure will trim leading (.) if first five char is '.THE''. The procedure performs the required task. I want to make select statement with bind variable is there any possibility to use a bind variable in this select statement.
    the procedure is given below:
    create or replace procedure test(tablename in varchar2, fieldname IN varchar2)
    authid current_user
    is
    type poicurtype is ref cursor;
    poi_cur poicurtype;
    sqlst varchar2(250);
    THEVALUE NUMBER;
    begin
         sqlst:='SELECT EMPNO FROM '||TABLENAME||' WHERE SUBSTR('||FIELDNAME||',1,5)=''.THE ''';
         DBMS_OUTPUT.PUT_LINE(SQLST);
    OPEN POI_CUR FOR SQLST ;
    LOOP
         FETCH POI_CUR INTO THEVALUE;
              EXIT WHEN POI_CUR%NOTFOUND;
              DBMS_OUTPUT.PUT_LINE(THEVALUE);
              SQLST:='UPDATE '||TABLENAME|| ' SET '||FIELDNAME||'=LTRIM('||FIELDNAME||',''.'')';
              SQLST:=SQLST|| ' WHERE EMPNO=:X';
              DBMS_OUTPUT.PUT_LINE(SQLST);
                   EXECUTE IMMEDIATE SQLST USING THEVALUE;
    END LOOP;
    COMMIT;
    END TEST;
    Best Regards,

    So you want to amend each row individually? Is there some reason you're trying to make this procedure run as slow as possible?
    create or replace procedure test (tablename in varchar2, fieldname in varchar2)
    authid current_user
    is
       sqlst      varchar2 (250);
       thevalue   number := 1234;
    begin
       sqlst := 'update ' || tablename || ' set ' || fieldname || '= ltrim(' || fieldname || ',''.'')  where substr(' || fieldname
          || ',1,5) = ''.THE ''';
       dbms_output.put_line (sqlst);
       execute immediate sqlst;
    end test;will update every row that satisfies the criteria in a single statement. If there are 10 rows that start with '.THE ' then it will update 10 rows.

  • TableSelectMany selection state problem.

    Hi All,
    I have a 'TableSelectMany' component for which I am setting the selection state based on the row index. This is working fine. But when we click on any column which is sortable, the rows are getting sorted leaving the selection states in their previous positions(the same row indexes..). Can I make these selection states dynamic by making them dependent on the value of an attribute in the column(a primary/unique key)?
    If some one has done this kind of thing, can you help me in this.
    Regards,
    Anil Kumar K.

    Hi Frank,
    Thank you for responding. I am using ADF BC as the business service layer.
    The piece of code I have used is....(this may help you to understand the context in which I am using it.)
    HashMap hashMap = null;
    CoreTable waybillsTable = null;
    FacesContext context = null;
    StringTokenizer tokens = null;
    String waybillNos = null;
    String token = null;
    Row waybillRecord = null;
    RowKeySet rks = null;
    String waybill = null;
    *some lines of code to get the waybillNo into the hashmap.
    waybillsTable = this.getTable1();
    int rowcnt = waybillsTable.getRowCount();
    rks = new RowKeySet();
    /*Row index starts from 0. So,wb starts from 0 */
    for (counter = 0; counter < rowcnt; counter++) {
    //set the current Row in Table
    waybillsTable.setRowIndex(counter);
    //check if the current Row is available
    if (waybillsTable.isRowAvailable()) {
    //get data for the set Current Row
    waybillRecord = ((JUCtrlValueBindingRef)waybillsTable.getRowData()).getRow();
    if (waybillRecord != null) {
    if(waybillRecord.getAttribute("waybillNo")!=null){  //This is the attribute in the table
    waybill = waybillRecord.getAttribute("waybillNo").toString();
    if (hashMap != null && waybill != null) {
    if (hashMap.containsKey(waybill)) {
    //rks.getKeySet().add(new Integer(counter)); /*This did not work for this condition. */
    rks.getKeySet().add(waybillRecord.getKey());
    //test code added
    hashMap.remove(waybill);
    this.getTable1().getSelectionState().getKeySet().addAll(rks.getKeySet());

  • Help needed with a SELECT statement. How can I make it run faster?

    Hi,
    not sure if my brain is just too tired but I can't seem to crack this problem today.
    Here is my scenario.
    I have 2 tables
    TABLE1 (searchId INTEGER, routeId INTEGER);
    TABLE2 (routeId INTEGER, cityId INTEGER);
    There are indexes on all 4 columns.
    (routeId on TABLE1 is a primary key).
    In the data I am using, a given search has more than 500 routes, each route has between 10 and 300 cities among more than 4000 possible different cities.
    Now, what I want to create is the list of route couple, within a certain search, that do not have a single city in common.
    That list should populate a table with the following structure
    TABLE3 (searchId INTEGER, routeId1 INTEGER, routeId2 INTEGER)
    Here is the fastest select statement I have found so far.
    SELECT :searchId, t1.routeId, t2.routeId FROM table1 t1, table1 t2
    WHERE t1.searchId=:searchId AND t2.searchId=:searchId
    AND t1.routeId>t2.routeId
    AND NOT EXISTS (
    SELECT cityId FROM table2
    WHERE routeId=t1.routeId
    INTERSECT
    SELECT cityId FROM table2
    WHERE routeId=t2.routeId);
    But it still seem really slow to me.
    Any suggestion for an improved version is welcome.
    Thanks,
    Martin.
    Title was edited by:
    user453358

    I originaly posted this thread because I tought I was missing something "obvious" that would perform better that would make my SELECT statement perform better.
    So I did not want to go as deep as using TKPROOF yet.
    Here is the statistics I gets on my statement.
      1   SELECT t1.searchId,t1.routeId, t2.routeId id2
      2      FROM table1 t1, table1 t2
      3     WHERE t1.searchid=t2.searchid
      4      AND t1.searchId=91
      5      AND t1.routeId>t2.routeId
      6      AND NOT EXISTS (
      7             SELECT cityId FROM table2
      8              WHERE routeId=t1.routeId
      9             INTERSECT
    10             SELECT cityId FROM table2
    11*            WHERE routeId=t2.routeId)
    SQL> /
    43302 rows.
    Tidsåtgång: 00:01:55.02
    Körschema
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=9 Card=1 Bytes=14)         
       1    0   FILTER                                                             
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'table1' (TABLE) (Cost=1 Card=1 Bytes=7)                                                
       3    2       NESTED LOOPS (Cost=3 Card=1 Bytes=14)                          
       4    3         TABLE ACCESS (BY INDEX ROWID) OF 'table1' (TABLE) (Cost=2 Card=1 Bytes=7)
       5    4           INDEX (RANGE SCAN) OF 'table1_IDX1' (INDEX) (Cost=1 Card=1)                                                    
       6    3         INDEX (RANGE SCAN) OF 'table1_IDX1' (INDEX) (Cost=0 Card=1)                                                      
       7    1     INTERSECTION                                                     
       8    7       SORT (UNIQUE) (Cost=3 Card=108 Bytes=864)                      
       9    8         TABLE ACCESS (BY INDEX ROWID) OF 'table2' (TABLE) (Cost=2 Card=108 Bytes=864)                                 
      10    9           INDEX (RANGE SCAN) OF 'table2_IDX1' (INDEX) (Cost=1 Card=108)                                               
      11    7       SORT (UNIQUE) (Cost=3 Card=108 Bytes=864)                      
      12   11         TABLE ACCESS (BY INDEX ROWID) OF 'table2' (TABLE) (Cost=2 Card=108 Bytes=864)                                 
      13   12           INDEX (RANGE SCAN) OF 'table2_IDX1' (INDEX) (Cost=1 Card=108)                                               
    Statistik
              1  recursive calls                                                   
              0  db block gets                                                     
        2872765  consistent gets                                                   
              0  physical reads                                                    
            812  redo size                                                         
         964172  bytes sent via SQL*Net to client                                  
          32245  bytes received via SQL*Net from client                            
           2888  SQL*Net roundtrips to/from client                                 
         860256  sorts (memory)                                                    
              0  sorts (disk)                                                      
          43302  rows processed  Looks like a big number of consistent gets! Any idea how to improve on that?
    Martin.

  • Using if logic in the where clause of a select statement

    I have a select clause. And in the select clause there is a variable all_off_trt that can be 'Y' or 'N'.
    In the where clause I want to make it so that if a form variable is checked and all_off_trt is 'Y' then
    exclude it else if the form variable isn't checked then select it no matter what all_off_trt is.
    Is there any way to include either and if statement or a case statement within the where clause to acheive this? If not is there another way of doing it?
    Basically I am looking for a case statement like this
    case
    when all_off_trt = 'Y' and mail_para.code = 'Y' then false
    else true
    end
    Message was edited by:
    Tugnutt7

    Ok, so that really doesn't solve my problem. I have 3 different fields that I need to do that with. Each combining in a select statement to print an email list, as well as other thing limiting the where clause.
    This is currently what I have, tested and working 100%.
    cursor email_cur is
         select unique p.email,s.all_off_trt,s.all_deceased,s.no_enroll
    from participant p, trialcom t, ethics s
    where p.status='A'
    and p.surname=t.surname
    and p.initials=t.initials
    and s.trial_cd = t.tricom
    and s.centre = t.centre
    and p.email is not null
    and (t.centre in (select code from mail_parameters where user_name=user and mail_para='CENTRE')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='CENTRE'))
    and (t.tricom in (select code from mail_parameters where user_name=user and mail_para='TRIAL')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='TRIAL'))
    and (t.role in (select code from mail_parameters where user_name=user and mail_para='ROLE')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='ROLE'))
    and (p.country in (select code from mail_parameters where user_name=user and mail_para='COUNTRY')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='COUNTRY'))
    and (t.represent in (select code from mail_parameters where user_name=user and mail_para='REPRESENT')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='REPRESENT'));
    This is in a program unit that runs when a button is clicked. At the end of that I need to add on the 3 case statements that help further narrow down the selection of emails to be printed. Then it prints the emails selected from this statement into a file. So it has to be done right in the select statement. The three table variables are the all_off_trt, all_deceased, and no_enroll. The form has 3 checkboxes. One for each, that when checked (giving the variable associated with the checkboxes a value of 'Y') excludes all emails that have a 'Y' in the coresponding table variable.

  • A trouble with "LIKE" in a select statement

    Hi!
    I'm having trouble with "LIKE" in a select statement...
    With Access I can make the following and everything works well:
    SELECT name, birthday
    FROM client
    WHERE birthday LIKE '*/02/*';
    but if try to do it in my application (it uses Access), it doesn't work - I just can't understand that!!!
    In my application the "month" is always the currently month taken from the "System". Look what I'm doing...
    String query1 = "SELECT name, birthday " +
              "FROM client " +
              "WHERE birthday " +
              "LIKE '*/" +
              pMonth +
              "/*' " +
              "ORDER BY birthday ASC ";
    ResultSet rs = statement1.executeQuery(consulta1);
    boolean moreRecords = rs.next();
    The variable "moreRecords" is always "false", the query returns nothing although the table "client" has records that attend the query.
    Please, anyone can help me?! It's a little bit urgent.
    Thanks,
    Katia.

    Hi Katia,
    I'll bet the problem lies with the characters you're using to escape the LIKE clause. You're using the ones that Access likes to see, but that's not necessarily what's built into the JDBC-ODBC driver class.
    You can find out what the correct escape wildcard characters are from the java.sql.DatabaseMetaData.getSearchStringEscape() method. It'll tell you what to use in the LIKE clause.
    I'm not 100% sure about your code. It doesn't use query1 anywhere. I'd do this:
    String query = "SELECT name, birthday FROM client WHERE birthday LIKE ? ORDER BY birthday ASC";
    PreparedStatement statement = connection.createStatement(query);
    String escape = connection.getMetaData().getSearchStringEscape();
    String test = escape + '/' + pMonth + '/' + escape;
    statement.setString(1, test);
    ResultSet rs = statement.executeQuery();
    while (rs.hasNext())
    // load your data into a data structure to pass back.
    rs.close();
    statement.close();Let me know if that works. - MOD

  • Select statement in a function does Full Table Scan

    All,
    I have been coding a stored procedure that writes 38K rows in less than a minute. If I add another column which requires call to a package and 4 functions within that package, it runs for about 4 hours. I have confirmed that due to problems in one of the functions, the code does full table scans. The package and all of its functions were written by other contractors who have been long gone.
    Please note that case_number_in (VARCHAR2) and effective_date_in (DATE) are parameters sent to the problem function and I have verified through TOAD’s debugger that their values are correct.
    Table named ps2_benefit_register has over 40 million rows but case_number is an index for that table.
    Table named ps1_case_fs has more than 20 million rows but also uses case_number as an index.
    Select #1 – causes full table scan runs and writes 38K rows in a couple of hours.
    {case}
    SELECT max(a2.application_date)
    INTO l_app_date
    FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
    WHERE a2.case_number = case_number_in and
    a1.case_number = a2.case_number and
    a2.application_date <= effective_date_in and
    a1.DOCUMENT_TYPE = 'F';
    {case}
    Select #2 – runs – hard coding values makes the code to write the same 38K rows in a few minutes.
    {case}
    SELECT max(a2.application_date)
    INTO l_app_date
    FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
    WHERE a2.case_number = 'A006438' and
    a1.case_number = a2.case_number and
    a2.application_date <= '01-Apr-2009' and
    a1.DOCUMENT_TYPE = 'F';
    {case}
    Why using the values in the passed parameter in the first select statement causes full table scan?
    Thank you for your help,
    Seyed
    Edited by: user11117178 on Jul 30, 2009 6:22 AM
    Edited by: user11117178 on Jul 30, 2009 6:23 AM
    Edited by: user11117178 on Jul 30, 2009 6:24 AM

    Hello Dan,
    Thank you for your input. The function is not determinsitic, therefore, I am providing you with the explain plan. By version number, if you are refering to the Database version, we are running 10g.
    PLAN_TABLE_OUTPUT
    Plan hash value: 2132048964
    | Id  | Operation                     | Name                    | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT              |                         |   324K|    33M|  3138   (5)| 00:00:38 |       |       |
    |*  1 |  HASH JOIN                    |                         |   324K|    33M|  3138   (5)| 00:00:38 |       |       |
    |   2 |   BITMAP CONVERSION TO ROWIDS |                         |     3 |     9 |     1   (0)| 00:00:01 |       |       |
    |*  3 |    BITMAP INDEX FAST FULL SCAN| IDX_PS2_ACTION_TYPES    |       |       |            |          |       |       |
    |   4 |   PARTITION RANGE ITERATOR    |                         |   866K|    87M|  3121   (4)| 00:00:38 |   154 |   158 |
    |   5 |    TABLE ACCESS FULL          | PS2_FS_TRANSACTION_FACT |   866K|    87M|  3121   (4)| 00:00:38 |   154 |   158 |
    Predicate Information (identified by operation id):
       1 - access("AL1"."ACTION_TYPE_ID"="AL2"."ACTION_TYPE_ID")
       3 - filter("AL2"."ACTION_TYPE"='1' OR "AL2"."ACTION_TYPE"='2' OR "AL2"."ACTION_TYPE"='S')
    Thank you very much,
    Seyed                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to model in OWB if you have a subquery in your select statement? (11.2)

    Which operator (is it the Table operator) to use if I have a subquery as part of my select statement? (The way I do it works, but is not elegant. What I do is create a table for the subquery and than join that with the other sources to point to my target.) But, would appreciate the best way with OWB's features.
    Here is the entire SQL (including the subquery):
    SELECT to_numbe (null), course_id
    at.book, lp.NAME,
    (select b.pricing from qp_pricing_attributes b
    where b.list_id = ll.list_id and b.product = at.product) sign,
    ll.operand AS price, lhb.comments
    FROM
    pricing_attribs at,
    list_lines ll,
    list_h lp,
    list_b lhb
    WHERE 1 = 1
    and ll.list_line_id = atrib.list_line_id
    AND ll.list_header_id = lp.list_header_id
    AND lp.list_header_id = lhb.list_header_id
    Thanks you.

    Hi
    Doesn't need to be a table in the target. Let's take a very simple example, let's say you wanted to do the following;
    select ename,(select dname from dept d where d.deptno=e.deptno) from emp e
    Then DEPT is your lookup table and EMP is your driving table.
    1. Add EMP on to the canvas.
    2. Add in lookup operator
    3. Bind lookup to DEPT
    4. Hit finish
    5. Map EMP.DEPT to DEPT.INGRP1 (the lookup operator)
    6. Edit lookup operator, on Lookup Conditions tab set DEPTNO for lookup column, and DEPTNO for input attribute
    7. Lookup complete now
    You can add in a target table operator and map from the source EMP table and the output attributes of the lookup operator. you can change step 4 to carry on through wizard and define lookup, but I have chosen to do 5, to automatically get the names and datatypes of the inputs. There are lot of other options now in 11gR2 in the lookup.
    Hope this makes sense.
    Cheers
    David

  • Values from a Multi-Select in the where clause of a Select statement

    I have a web page that solicits query parameters from the user.
    The selections that the user makes will populate the WHERE clause of a Select statement.
    One of the controls on the page is a multi-select control.
    When this page posts, I would like to execute a Select statement wherein the selected values from this control appear in the .. Column IN ( <list here> ) portion of the WHERE clause.
    This is an extremely common scenario, but I cannot seem to locate a how-to or message thread that addresses this specific case.
    I have an idea that it may involve dynamic SQL or Execute Immediate, but cannot seem to pin down the answer.
    Any help would be greatly appreciated!

    anonymous - As illustrated here: Re: Search on a typed in list of values
    Scott

  • Does BOBJ support OR select statement against SAP BW

    Hello,
    We are looking at BOBJ for reporting against SAP BW, and I was wondering if BOBJ supports select OR statements and select AND statements in the same report.
    For example.
    We have three select parameters:
    Company Code
    Document Type
    Vendor
    The business would like to run the following select statements:
    Company Code = 1010 AND
    Document Type = WE OR
    Vendor = 123123
    or from the same query, run the report this way:
    Company Code = 1010 AND
    Document Type = WE AND
    Vendor = 123123
    Is this possible? If yes, what options do we have.

    Hi Bill,
    there are several options to achieve this:
    In the BI Query you have a parameter type that is called "selection option" which allows the end-user to create very complex selection.
    In Crystal Reports you can create your own filter / parameters but you would have to pay attention to make sure that the parameters are being send down to the server.
    in Web Intelligence / a Universe you could do the same like in CR.
    Ingo

  • Performance Issue in select statements

    In the following statements, it is taking too much time for execution,Is there any best way to change these selection statements...int_report_data is my final internal table....
    select fsplant fvplant frplant fl1_sto pl1_delivery pl1_gr pl2_sto           pl2_delivery perr_msg into (dochdr-swerks,dochdr-vwerks,dochdr-rwerks,dochdr-l1sto,docitem-l1xblnr, docitem-l1gr,docitem-l2sto,  docitem-l2xblnr,docitem-err_msg) from zdochdr as f inner join zdocitem as p on fl1_sto  =  pl1_sto where fsplant in s_werks and
    fvplant in v_werks and frplant  in r_werks and pl1_delivery in l1_xblnr and pl1_gr in l1_gr and p~l2_delivery in l2_xblnr.
    move : dochdr-swerks    to  int_report_data-i_swerks,
            dochdr-vwerks    to  int_report_data-i_vwerks,
            dochdr-rwerks    to  int_report_data-i_rwerks,
            dochdr-l1sto     to  int_report_data-i_l1sto,
            docitem-l1xblnr  to  int_report_data-i_l1xblnr,
            docitem-l1gr     to  int_report_data-i_l1gr,
            docitem-l2sto    to  int_report_data-i_l2sto,
            docitem-l2xblnr  to  int_report_data-i_l2xblnr,
            docitem-err_msg  to  int_report_data-i_errmsg.
            append int_report_data.
        endselect.
    Goods receipt
    loop at int_report_data.
    select single ebeln from ekbe into l2gr where ebeln = int_report_data-i_l2sto and bwart = '101' and bewtp = 'E' and vgabe = '1'.
    if sy-subrc eq 0.
           move l2gr to int_report_data-i_l2gr.
           modify int_report_data.
       endif.
    endloop.
    first Billing document (I have to check fkart = ZRTY for second billing *document..how can i write the statement)
    select vbeln from vbfa into (tabvbfa-vbeln) where vbelv = int_report_data-i_l2xblnr or vbelv = int_report_data-i_l1xblnr.
    select single vbeln from vbrk into tabvbrk-vbeln where vbeln = tabvbfa-vbeln and fkart = 'IV'.
      if sy-subrc eq 0.
             move tabvbrk-vbeln to int_report_data-i_l2vbeln.
             modify int_report_data.
       endif.
       endselect.
    Thanks in advance,
    Yad

    Hi!
    Which of your selects is slow? Make a SQL-trace, check which select(s) is(are) slow.
    For EKBE and VBFA you are selecting first key field - in general that is fast. If your z-tables are the problem, maybe an index might help.
    Instead of looping and making a lot of select singles, one select 'for all entries' can help, too.
    Please analyze further and give feedback.
    Regards,
    Christian

  • Calculation using multiple select statements - APEX 4.0

    Hello,
    I am new to APEX, PL/SQL and have some SQL knowledge, but I pick up things quickly. I want to make a page item equal to the value of a Select statement minus another Select statement. The statements pull from the same tables and only differ slightly in the where clause. I do not know the best way to create this calculation. Can someone please assist.
    Select Statement #1
    select     sum(JE_TRANSACTIONS.DEBIT_AMOUNT) as "Release"
    from     "REVREC_FORMS" "REVREC_FORMS",
         "JOURNAL_ENTRIES" "JOURNAL_ENTRIES",
         "JE_TRANSACTIONS" "JE_TRANSACTIONS"
    where "JOURNAL_ENTRIES"."RELATED_REVREC"="REVREC_FORMS"."REVREC_ID"
    and     "JOURNAL_ENTRIES"."RECORD_ID_"="JE_TRANSACTIONS"."RELATED_JOURNAL_ENTRY"
    and      "JOURNAL_ENTRIES"."RELEASE_TYPE" ='Release'
    and     "JOURNAL_ENTRIES"."REVENUE_TYPE" ='Software'
    and     "REVREC_FORMS"."REVREC_ID" =:P12_REVREC_ID
    Select Statement #2
    select     sum(JE_TRANSACTIONS.DEBIT_AMOUNT) as "Deferral"
    from     "REVREC_FORMS" "REVREC_FORMS",
         "JOURNAL_ENTRIES" "JOURNAL_ENTRIES",
         "JE_TRANSACTIONS" "JE_TRANSACTIONS"
    where "JOURNAL_ENTRIES"."RELATED_REVREC"="REVREC_FORMS"."REVREC_ID"
    and     "JOURNAL_ENTRIES"."RECORD_ID_"="JE_TRANSACTIONS"."RELATED_JOURNAL_ENTRY"
    and      "JOURNAL_ENTRIES"."RELEASE_TYPE" ='Deferral'
    and     "JOURNAL_ENTRIES"."REVENUE_TYPE" ='Software'
    and     "REVREC_FORMS"."REVREC_ID" =:P12_REVREC_ID

    How about
    select   sum(decode(release_type,'Deferral',je_transactions.debit_amount)) - sum(decode(release_type,'Release',je_transactions.debit_amount)) as result
    from   "REVREC_FORMS" "REVREC_FORMS",
    "JOURNAL_ENTRIES" "JOURNAL_ENTRIES",
    "JE_TRANSACTIONS" "JE_TRANSACTIONS"
    where "JOURNAL_ENTRIES"."RELATED_REVREC"="REVREC_FORMS"."REVREC_ID"
    and  "JOURNAL_ENTRIES"."RECORD_ID_"="JE_TRANSACTIONS"."RELATED_JOURNAL_ENTRY"
    and  "JOURNAL_ENTRIES"."REVENUE_TYPE" ='Software'
    and  "REVREC_FORMS"."REVREC_ID" =:P12_REVREC_IDScott

  • How to use the select statement in for loop

    Hi All,
    my question is can we use select statement in for loop like as follows .
    for key in select key from one_table.
    when i am using this am getting an error like Found select invalid i identifier
    how to make use of select statement in for loop
    please suggest me .
    Thanks
    Sree

    SQL>set serveroutput on;
    SQL> DECLARE
         BEGIN
         FOR Cur_Rec IN (SELECT dname FROM dept) LOOP
          DBMS_OUTPUT.PUT_LINE(Cur_Rec.dname);
         END LOOP;
         END;
    SQL>
    ACCOUNTING
    RESEARCH
    SALES
    OPERATIONSAs per your requirement always filter the Query beforehand
    Like
    FOR Cur_Rec IN (SELECT key FROM <table> WHERE key=1) LOOP
    END LOOP;Edited by: Lokanath Giri on १ दिसंबर, २०११ ३:५६ अपराह्न

  • How to use column name as variable in select statement

    hi,
    i want to make a sql query where in select statement using variable as a column name. but its not working plz guide me how can i do this.
    select :m1 from table1;
    regards

    Hi,
    Is this what you want..
    SQL> select &m1 from dept;
    Enter value for m1: deptno
    old   1: select &m1 from dept
    new   1: select deptno from dept
        DEPTNO
            10
            20
            30
            40
    SQL> select &m1 from dept;
    Enter value for m1: dname
    old   1: select &m1 from dept
    new   1: select dname from dept
    DNAME
    ACCOUNTING
    RESEARCH
    SALES
    OPERATIONS
    SQL> select &&m1 from dept;
    Enter value for m1: loc
    old   1: select &&m1 from dept
    new   1: select loc from dept
    LOC
    NEW YORK
    DALLAS
    CHICAGO
    BOSTON
    SQL> select &&m1 from dept;
    old   1: select &&m1 from dept
    new   1: select loc from dept
    LOC
    NEW YORK
    DALLAS
    CHICAGO
    BOSTONIf you use single '&' then each time you fire the query, It will ask for the new value..
    But if you will use double '&&' the value of m1 will be persistent across the session..
    Twinkle

Maybe you are looking for