Select query based on userinput

Hi Folks...
I posted this in another forum, but no reply,so I am posting it here too. I am trying to make a select query based on a user input. Earlier I was having probelms making a select query and printing out the result in the stack trace,with the advice given, I managed to solve that. I am now modifying that code to make a query based on user input, however it's not working, following is the code:
String userId = request.getRemoteUser();  String sql = "SELECT hoursused FROM sysuser WHERE iduser = ?";    try      {        Connection connection = dataSource.getConnection();        PreparedStatement preparedStatement = connection.prepareStatement(sql);        preparedStatement.setString(1, userId);                ResultSet srs = preparedStatement.executeQuery(sql);                            while(srs.next()) {                          String hoursused = srs.getString("hoursused");                          System.out.println("The hours used are " + hoursused);    }                  }    catch (SQLException e)      {    e.printStackTrace();    }        } 
stack trace seems to suggest I may have a probelm with this statement:
"SELECT hoursused FROM sysuser WHERE iduser = ?"; 
I am not sure how to rectify this, I hope someone can advise, thanks.

Hi jschell..
Thanks for responding, I appreciate it. The problem has been solved. No 'sysuser' is not a reserved word in Mysql. Based on the advice given in another forum and also from this site, I managed to solve the problem. I only made one change. This:
ResultSet srs = preparedStatement.executeQuery(sql);     was changed to this:
ResultSet srs = preparedStatement.executeQuery();  Thanks.

Similar Messages

  • SELECT QUERY  BASED ON SECONDARY INDEX

    Hi all,
    CAN ANYONE TELL ME HOW TO WRITE SELECT QUERY BASED ON SECONDARY INDEX.
    IN WHAT WAY DOES IT IMPROVE PERFORMANCE.
    i KNOW WHEN CREATING SECONDARY INDEX I NEED TO GIVE AN INDEX NO -iT SHOULD BE ANY NUMBER RIGHT?
    I HAVE TO LIST ALL PRIMARY KEYS FIRST AND THEN THE FIELD FOR WHICH I AM CREATING SECONDARY INDEX RIGHT?
    LETS SAY I HAVE 2 PRIMARY KEYS AND I WANT TO CREATE SEONDARY INDEX FOR 2 FIELDS THEN
    I NEED TO CREATE A SEPERTE SECONDARY INDEX FOR EACH ONE OF THOSE FIELDS OR ONE SHOULD BE ENOUGH
    pLS LET ME KNOW IF IAM WRONG

    HI,
    If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVINGclauses, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
    You create secondary indexes using the ABAP Dictionary. There you can create its columns and define it as UNIQUE. However, you should not create secondary indexes to cover all possible combinations of fields.
    Only create one if you select data by fields that are not contained in another index, and the performance is very poor. Furthermore, you should only create secondary indexes for database tables from which you mainly read, since indexes have to be updated each time the database table is changed. <b>As a rule, secondary indexes should not contain more than four fields</b>, <b>and you should not have more than five indexes for a single database table</b>.
    <b>What to Keep in Mind for Secondary Indexes:</b>
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eb2d446011d189700000e8322d00/content.htm
    http://www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
    Regards
    Sudheer

  • Select Query Based on date condition

    Hi ,
    Is it Possible.
    i want to run select query based on date condition.
    Eg...
    if the date between 01-jan-01 and 01-jan-05 then
    select * from table1;
    if the date between 02-jan-05 and 01-jan-08 then
    select * from table2;
    Becaz i have data in 2 diffrent tables , based on the date condition i wnt to run the select statement to diffrent tables.
    i dont want plsql here Just SQL needed.
    thanks,
    -R
    Edited by: infant_raj on May 5, 2009 11:48 PM

    Helo Kanish,
    this is not the one i was asking..
    wht i mean was .
    i use bind variable to get date while running the select statement , once i get the date then i want to choose any one of the table to run select query.
    EG..
    select col1,col2 from table1 where date between only if 01-jan-01 and 01-jan-05;
    select col1,col2 from table2 where date between only if 02-jan-05 and 01-jan-08;
    Run any one of the two . not all
    thanks,
    _raj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Select query based LOV for tabular form attributes

    Hi HTMLDB Team,
    Congrats u all for the new release of HTMLDB in htmldb.oracle.com.
    I badly need a solution of the below problem.
    Say , i have table called user_col_comments now i want to display the table_name ,column_name and comments in a tabular form.I displayed only one row for the tabular form.Now i create a select query based LOV for attribute table_name where i got all table_name in drop down list.
    Point is that after selecting any data from drop down table list i want to get the corresponding fields to be populated in column_name attributes.How can i wrote the select query based LOV for the attibute column_name.
    I wrote it as 'select column_name d,column_name r from user_col_comments where table_name=:TABLE_NAME Its not working?
    Similarly i want same thing to display for comments after matching both table_name and column_name.
    Any solution to get rid of those problem will be highly appreciable...
    If u need my htmldb.oracle.com userid and password to solve the problem i will sure let u email it.
    Cheers,
    Eman

    hi rchalton,
    can u plz little bit more clearer .I know hopefully u can imagine the problem and may u guide me thru proper way.....One think i understand that there must be multiple process and submit but "only when..." that u have said i cant understand that part........
    U are welcome to give me proper solution.....
    Thanks for the reply ....atleast one can pay hid to me.....
    Cheers,
    Eman

  • Select query based on joining of tables from different database is taking too long

    Hi Team,
    Select query on table with millions of records is taking very long time. It took 50mins, the below query is joining on multiple table from two databases DB1.dbo.Table1 contains 100 million records and also Table3 and Table4 (of different database) might
    contain close to 1million records.
    Select T1.*
    From DB1.dbo.Table1 T1
    Join DB1.dbo.Table2 T2 on RTRIM(T1.Col3) = RTRIM(T2.Col3)
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    Join Table3 U on CA.Col2 = U.Col2 AND RTRIM(T2.Col2) = U.Col3
    Where U.Col4 NOT IN ('A1', 'A2', 'A3', 'A4', 'A5', 'A6','A7','A8','A9')
    And (T1.flg IS NULL OR T1.flg = 'N')
    And LTRIM(RTRIM(T2.Col2)) NOT IN ('B1','B2')
    How can i improve the performance of this query. Actual thing is update the data in Db1.dbo.table1 based on the conditions but if the select is taking close to 1hr then update will take hours together. Indexes already implemented on all the tables.
    Thanks,
    Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

    Thanks.
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    This join is not working with spaces if Rtrim is not used.
    Thanks! Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

  • Want to select query based on sample data.

    My Oracle Version
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    I am creating inventory valuation report using FIFO method . here sample data .
    create table tranx(
    TRXTYPE     varchar2(10) ,ITEM_CODE varchar2(10),     RATE number,qty number
    insert into tranx values('IN'     ,'14042014',     457.2     ,10);
    insert into tranx values('OUT','14042014',     0,          10);
    insert into tranx  values('IN','14042014',     458.1,     35);
    insert into  tranx values('OUT','14042014',     0,          11);
    insert into  tranx values('OUT','14042014',     0,          6);
    insert into  tranx values('IN','     14042014',     457.2     ,10);
    insert into tranx  values('OUT','     14042014',     0,          3);
    insert into tranx  values('OUT','     14042014',     0,          4);
    insert into tranx  values('IN','     14042014',     457.2,     20);
    insert into tranx  values('OUT','     14042014',     0,          5);
    insert into tranx  values('OUT','     14042014',     0,          9);
    insert into tranx  values('OUT','     14042014',     0,          8);
    current output
    TRXTYPE     ITEM_CODE     RATE      QTY
    IN     14042014     457.2     10
    OUT     14042014     0          10
    IN     14042014     458.1     35
    OUT     14042014     0          11
    OUT     14042014     0          6
    IN     14042014     457.2     10
    OUT     14042014     0          3
    OUT     14042014     0          4
    IN     14042014     457.2     20
    OUT     14042014     0          5
    OUT     14042014     0          9
    OUT     14042014     0          8above data populate based on first in first out . but out rate is not comes from that query. suppose fist 10 qty are OUT its rate same as IN. but when qty start out from 35 rate will be 458.1 till all 35 qty will not out. like out qty 11,6,3,4,5,9 now total are 38 .
    when qty 9 will out the rate are 6 qty rate 458.1 and other 3 out rate of 457.2 means total value of 9 out qty value is 4120.20 .
    Now 35 qty is completed and after that rate will continue with 457.2 till 10 qty not completed.
    I think you understand my detail if not please tell me .
    thanks
    i am waiting your reply.

    As SomeoneElse mentioned, there is no row order in relational tables, so you can't tell which row is first and which is next unless ORDER BY is used. So I added column SEQ to your table:
    SQL> select  *
      2    from  tranx
      3  /
    TRXTYPE    ITEM_CODE        RATE        QTY        SEQ
    IN         14042014        457.2         10          1
    OUT        14042014            0         10          2
    IN         14042014        458.1         35          3
    OUT        14042014            0         11          4
    OUT        14042014            0          6          5
    IN         14042014        457.2         10          6
    OUT        14042014            0          3          7
    OUT        14042014            0          4          8
    IN         14042014        457.2         20          9
    OUT        14042014            0          5         10
    OUT        14042014            0          9         11
    TRXTYPE    ITEM_CODE        RATE        QTY        SEQ
    OUT        14042014            0          8         12
    12 rows selected.
    SQL> Now it can be solved. Your task requires either hierarchical or recursive solution. Below is recursive solution using MODEL:
    with t as (
               select  tranx.*,
                       case trxtype
                         when 'IN' then row_number() over(partition by item_code,trxtype order by seq)
                         else 0
                       end rn_in,
                       case trxtype
                         when 'OUT' then row_number() over(partition by item_code,trxtype order by seq)
                         else 0
                       end rn_out,
                       count(case trxtype when 'OUT' then 1 end) over(partition by item_code) cnt_out
                 from  tranx
    select  trxtype,
            item_code,
            rate,
            qty
      from  t
      model
        partition by(item_code)
        dimension by(rn_in,rn_out)
        measures(trxtype,rate,qty,qty qty_remainder,cnt_out,1 current_in,seq)
        rules iterate(10) until(iteration_number + 1 = cnt_out[0,1])
         rate[0,iteration_number + 1]          = rate[current_in[1,0],0],
         qty_remainder[0,iteration_number + 1] = case sign(qty_remainder[0,cv() - 1])
                                                   when 1 then qty_remainder[0,cv() - 1] - qty[0,cv()]
                                                   else qty[current_in[1,0],0] - qty[0,cv()] + nvl(qty_remainder[0,cv() - 1],0)
                                                 end,
         current_in[1,0]                       = case sign(qty_remainder[0,iteration_number + 1])
                                                   when 1 then current_in[1,0]
                                                   else current_in[1,0] + 1
                                                 end
      order by seq
    TRXTYPE    ITEM_CODE        RATE        QTY
    IN         14042014        457.2         10
    OUT        14042014        457.2         10
    IN         14042014        458.1         35
    OUT        14042014        458.1         11
    OUT        14042014        458.1          6
    IN         14042014        457.2         10
    OUT        14042014        458.1          3
    OUT        14042014        458.1          4
    IN         14042014        457.2         20
    OUT        14042014        458.1          5
    OUT        14042014        458.1          9
    TRXTYPE    ITEM_CODE        RATE        QTY
    OUT        14042014        457.2          8
    12 rows selected.
    SQL> SY.

  • Select query based on Simple Type field in JDT

    Hello Experts,
    We have a JDT table consisting of a field "CONSUMPTION_ID" which refers to a Simpletype.So at oracle level the datatype of the field shows as CLOB instead of String. I am unable to use this simple type field in the WHERE clause in my bean .
    Following are the queries i have tried and the errors i have got executing them :
    Query1 -  SELECT * FROM TEST_TABLE WHERE CONSUMPTION_ID <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM "TEST_TABLE " WHERE "REF_MAT_DOC_NO" = ? AND "REF_MAT_DOC_YEAR" = ? AND "CONSUMPTION_ID" <> 'RT'" contains the semantics error[s]: - 1:84 - type check error: the expression >>"CONSUMPTION_ID"<< (CLOB) is not comparable and must not be used with "<>"
    - 1:84 - type check error: the left hand side >>"CONSUMPTION_ID"<< (CLOB) and the right hand side >>'RT'<< (CHAR) of a comparison operator are not comparable
    Query 2 - SELECT * FROM TEST_TABLE WHERE to_char(CONSUMPTION_ID) <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM TEST_TABLE  WHERE REF_MAT_DOC_NO = ? AND REF_MAT_DOC_YEAR = ? AND to_char(CONSUMPTION_ID) <> 'RT'" contains the syntax error[s]: - 1:91 - SQL syntax error: the token "(" was not expected here
    Please let me know if any one has used WHERE clause on fields which refer to a simpletype in JDT, or any other solution to the above problem
    Regards,
    Virag

    Hello Experts,
    We have a JDT table consisting of a field "CONSUMPTION_ID" which refers to a Simpletype.So at oracle level the datatype of the field shows as CLOB instead of String. I am unable to use this simple type field in the WHERE clause in my bean .
    Following are the queries i have tried and the errors i have got executing them :
    Query1 -  SELECT * FROM TEST_TABLE WHERE CONSUMPTION_ID <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM "TEST_TABLE " WHERE "REF_MAT_DOC_NO" = ? AND "REF_MAT_DOC_YEAR" = ? AND "CONSUMPTION_ID" <> 'RT'" contains the semantics error[s]: - 1:84 - type check error: the expression >>"CONSUMPTION_ID"<< (CLOB) is not comparable and must not be used with "<>"
    - 1:84 - type check error: the left hand side >>"CONSUMPTION_ID"<< (CLOB) and the right hand side >>'RT'<< (CHAR) of a comparison operator are not comparable
    Query 2 - SELECT * FROM TEST_TABLE WHERE to_char(CONSUMPTION_ID) <> 'RT'
    Error - com.sap.sql.log.OpenSQLException: The SQL statement "SELECT * FROM TEST_TABLE  WHERE REF_MAT_DOC_NO = ? AND REF_MAT_DOC_YEAR = ? AND to_char(CONSUMPTION_ID) <> 'RT'" contains the syntax error[s]: - 1:91 - SQL syntax error: the token "(" was not expected here
    Please let me know if any one has used WHERE clause on fields which refer to a simpletype in JDT, or any other solution to the above problem
    Regards,
    Virag

  • Problem in select query

    Hi Friends
    I am using a table a981 and fetching data in internal table but the table has a fieil Country whose technical name is ALAND in dev and LAND1 in production.Now i cannot use LAND1 as it wont let me to activate the report and if i use ALAND i cannot move the request to production as it fails. So how can i achive dynamic table field in the select query based on server.My query is-
    select kschl
               wkreg
               matnr
               knumh
       from a981 into corresponding fields of table it_a981
       for all entries in it_marc where matnr = it_marc-matnr
                                    and kschl in ('MWST','ZSER')
                                    and aland = 'IN'
                                    and datab le sy-datum
                                    and datbi ge sy-datum.
    I need to make aland dynamic.Pls suggest

    If you insist on having a workaround, you could always create dynamic WHERE conditions.
    DATA: cond TYPE string.
    IF sy-sysid EQ <your dev sysid>.
        cond = 'matnr = it_marc-matnr
                and kschl in (''MWST'',''ZSER'')
                and datab le sy-datum
                and datbi ge sy-datum'
                and land1 = ''IN''.
    ELSE.
        cond = 'matnr = it_marc-matnr
                and kschl in (''MWST'',''ZSER'')
                and datab le sy-datum
                and datbi ge sy-datum'
                and aland = ''IN''.
    ENDIF.
    select kschl
               wkreg
               matnr
               knumh
       from a981 into corresponding fields of table it_a981
       for all entries in it_marc where (cond).
    Kyle

  • How to write XSJS Select Query with input parameters

    Hello Experts,
    I am creating a xsjs file and in that file I am trying to write a Select Query based on a Calculation View
    I have tried it the following way:
    var query = 'SELECT TOP 100 \"Name\", \"Address\", \"City\", \"Country\" FROM \"_SYS_BIC\".\"Test.HL/AddressView\"'
        + 'WITH PARAMETERS(\'PLACEHOLDER\' = (\'$$P_Name$$\', \' Akhil \'),'
      + '\'PLACEHOLDER\' = (\'$$P_City$$\', \' Lucknow \'))';
    But it gives me the "Mixed spaces and tabs error".
    How should I write XSJS Select Query with input parameters?
    Regards,
    Rohit

    >But it gives me the "Mixed spaces and tabs error".
    Mixed spaces and tabs has nothing to do with the syntax of the statement. You used both spaces and the tab in the content - which JSLint doesn't like.  Remove the beginning spaces of each line and use only one or the other.
    The actual syntax of your statement doesn't look right.  The problem is that you are escaping the \ when you don't need to if you are using ' instead of " for your string.  You escape with \" in the first line but then escape with \' in the 2nd and 3rd line.  That is going to cause serious parsing problems with the command.

  • Passing parameters to select query in DB link from invoke...

    I am having a DB partner link which executes the select query based on user specified parameter.
    Now i have created an invoke activity and specified input[this needs to be passed to query] and output parameters[this is query result]. This invoke activity calls DB partner link in which one parameter has been created to be used in select query. So my doubt is , will DB partner link take up the input parameter of invoke activity automatically or do we need to specify any mapping for this?

    When you create a db partnerlink the parameter you create for your select is the input and when you create the input variable in the invoke for this partnerlink it is created with the right type for the parameter.
    Create an Assign before your invoke and assign a value to the input variable you created in the invoke. That value will be passed and used as the parameter in the select.
    Heidi.

  • Select Query after the Event "GET  node "

    Hi,
    My requirements is I am calling get object event in my report and preparing an internal table in the get event, after this i need to write a select query based on this internal table..
    i want to avoid select query inside get event, my problem is to end the GET event and write a select query..
    How can i do that..
    can i write it in the end-of-selection.( i don't think so)
    it looks like this.
    start-of-selection.
    get objec.
    " Internal table preparation
    ????????event name needed??????????
    select query.....
    please suggest.

    END-OF-SELECTION.
    Effect
    This statement defines an event block, whose event is raised by the ABAP-runtime environment during the calling of an executable program , if the logical database, with which the program is linked, has completely finished its work.
    Moderator message - Sandeep - if you have to cut and paste from the help, please note it as such.
    Edited by: Rob Burbank on Nov 26, 2009 12:42 PM

  • Dynamic selection query

    Hi,
    I need to write a dynamic select query based on the user's selection.
    On Selection screen select options provided of fields like Company code, Plant and Sales Organazation.
    Now, I have find out how many tables having field company code(If User enters data in this field) from DD03L table. And, based on the data retrieved, how many entries does exists in those tables matching user criteria.
    Same thing for Plant and Sales Organization.
    Thanks in Advance.
    Nitin

    Hello Nitin,
    I was trying to write a code for your requirement ) I was got this short dump. Basically you need to capture this SQL exception.
    DATA:
      it_dd03l TYPE STANDARD TABLE OF dd03l,
      wa_dd03l TYPE dd03l,
      v_tabname TYPE string,
      v_tabname1 TYPE tabname.
    SELECT * FROM dd03l INTO TABLE it_dd03l
    WHERE fieldname = 'BUKRS'.
    IF sy-subrc = 0.
      LOOP AT it_dd03l INTO wa_dd03l.
        v_tabname = wa_dd03l-tabname.
        TRY.
            SELECT COUNT(*)
            FROM (v_tabname)
            WHERE bukrs = p_bukrs.
            IF sy-subrc = 0.
              v_tabname1 = v_tabname.
              WRITE: / v_tabname1, 35 sy-dbcnt.
            ENDIF.
          CATCH cx_sy_dynamic_osql_semantics.
        ENDTRY.
      ENDLOOP.
    ENDIF.
    Trust me, it will take hell lot of time to execute this report :-((
    BR,
    Suhas
    Edited by: Suhas Saha on Dec 17, 2008 12:08 PM

  • How can i update rows  in a table based on a match from a select query

    Hello
    How can i update rows in a table based on a match from a select query fron two other tables with a update using sqlplus ?
    Thanks Glenn
    table1
    attribute1 varchar2 (10)
    attribute2 varchar2 (10)
    processed varchar2 (10)
    table2
    attribute1 varchar2 (10)
    table3
    attribute2 varchar2 (10)
    An example:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)

    Hi,
    Etbin wrote:
    Hi, Frank
    taking nulls into account, what if some attributes are null ;) then the query should look like
    NOT TESTED !
    update table1 t1
    set processed = 'Y'
    where exists(select null
    from table2
    where lnnvl(attribute1 != t1.attribute1)
    and exists(select null
    from table3
    where lnnvl(attribute2 != t1.attribute2)
    and processed != 'Y'Regards
    EtbinYes, you could do that. OP specifically requested something else:
    wgdoig wrote:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)This WHERE clause won't be TRUE if any of the 4 attribute columns are NULL. It's debatable about what should be done when those columns are NULL.
    But there is no argument about what needs to be done when processed is NULL.
    OP didn't specifically say that the UPDATEshould or shouldn't be done on rows where processed was already 'Y'. You (quite rightly) introduced a condition that would prevent redo from being generated and triggers from firing unnecessarily; I'm just saying that we have to be careful that the same condition doesn't keep the row from being UPDATEd when it is necessary.

  • Problem writing a sql query for a select list based on a static LOV

    Hi,
    I have the following table...
    VALIDATIONS
    ID          Number     (PK)
    APP_ID          Number     
    REQUESTED     Date          
    APPROVED     Date          
    VALID_TIL     Date
    DEPT_ID          Number     (FK)
    I have a search form with the following field item variables...
    P11_DEPT_ID (select list based on dynamic LOV from depts table)
    P11_VALID (select list based on static Yes/No LOV)
    A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
    SELECT v.APP_ID,
    v.REQUESTED,
    v.APPROVED,
    v.VALID_TIL,
    d.DEPT
    FROM DEPTS d, VALIDATIONS v
    WHERE d.DEPT_ID = v.DEPT_ID(+)
    AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
    This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
    Can anyone help me to extend my query to include this situation?
    Thanks.

    Hello !
    Let's have a look at my example:create table test
    id        number
    ,valid_til date
    insert into test values( 1, sysdate-3 );
    insert into test values( 2, sysdate-2 );
    insert into test values( 3, sysdate-1 );
    insert into test values( 4, sysdate );
    insert into test values( 5, sysdate+1 );
    insert into test values( 6, sysdate+2 );
    commit;
    select * from test;
    def til=yes
    select *
      from test
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);
    def til=no
    select *                                                                               
      from test                                                                            
      where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
           =decode('&til','yes',1,-1);  
    drop table test;  It's working fine, I've tested it.
    The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
    For understandings:
    1.) TRUNC removes the time part of DATE
    2.) The difference of to date-values is the number of days between.
    3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
    4.) DECODE is like an IF.
    Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
    Good luck,
    Heinz

  • Select List (query based LOV) in a wizard created report form

    I have created an updatable report form with 3 columns:
    app_id
    user_id
    group_id
    Each app_id has multiple group_id's associated with it, and I want to show the group_id field as a Select List (query based LOV) that contains the groups associated with the app_id.
    My query for the select list needs to be similar to the following:
    SELECT DISPLAY_NAME, GROUP_ID
    FROM APPLICATION_GROUPS
    WHERE APP_ID = ?????
    ORDER BY 1
    The problem is, I don't know how to reference the app_id from the main report to replace the ?????.
    In other words, if my report returns 2 rows of data like this:
    app_id----------user_id----------group_id
    1-----------------24------------------3
    2-----------------24------------------15
    Then how do I get the group_id column to be a select list of possible groups for each application? If app_id 1 has 3 groups associated with it, 3, 4, & 5 and app_id 2 has 2 groups associated with it, 15 & 16, then those each of the select lists should be based on the app_id.
    Hopefully I explained this clearly.
    Thanks,
    Kris

    Leo,
    Thanks for the response, but I don't think you quite understand my problem. If I go to the Column Attributes screen for the group_id field, I have the "Display As" drop down set to "Select List (query based LOV)", not "Select List (named LOV)". This requires that the sql query be written in the "List of values definition" text area below. Within that text area I have the following query:
    SELECT DISPLAY_NAME, GROUP_ID
    FROM APPLICATION_GROUPS
    WHERE APP_ID = ?????
    ORDER BY 1
    The APP_ID that I need to reference is for the current row of data that is being processed. Therefore, I can't use a :PNNN_APP_ID variable, because that field does not exist on the page.
    Hopefully this explains it a little better.
    Thanks,
    Kris

Maybe you are looking for