Regarding WHERE clause

Hello,
I have a stupid question...
Let's suppose I have a query like this one:
SELECT *
   FROM table_t
WHERE ...
   AND TRUNC(SYSDATE) BETWEEN TO_DATE('01/01/2011', 'DD/MM/YYYY') and TO_DATE('02/01/2011', 'DD/MM/YYYY')And let's suppose this query takes a long time to execute because I'm having million records in the table. If I launch this query at 23:59 the 01/01/2011 and it takes more than one minutes to execute, I guess the first minute TRUNC(SYSDATE) will return 01/01/2011 and after midnight the TRUNC(SYSDATE) will return 02/01/2011 and the where clause is no more verified?
Is this how Oracle works or TRUNC(SYSDATE) is computed only once before running the WHERE clause?
Thanks for your help,

The SYSDATE is evaluated at the beginning of the statement. So, even if the system clock changes while the statement is running, it holds a "constant" (actually "consistent") value for TRUNC(SYSDATE).
Hemant K Chitale

Similar Messages

  • Regarding  dynamically assigning the where clause to select query

    hi,
      Please send the code regarding how to dynamically assign the where clause to select query.
    thanks in advance

    SELECT <fileds>
            INTO TABLE itab
            FROM dbase
            WHERE  condition.

  • Derive found flag in SQL with where clause using TABLE(CAST function

    Dear All,
    Stored procedure listEmployees
    ==========================
    CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
    empIdList STRING_ARRAY
    countriesList STRING_ARRAY
    SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
    FROM EMPLOYEE WHERE
    EMP_ID IN
    (SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
    AND EMP_COUNTRY IN
    (SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
    =================
    I have a stored procedure which lists the employees using above simple query.
    Here I am using table CAST function to find the list of employees in one go
    instead of looping through each and every employee
    Everything fine until requirements forced me to get the FOUND_FLAG as well.
    Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
    but I was not successful
    Can you please suggest if there is any intelligent way to say weather the
    row is found for given parameters in the where clause?
    If not I may have to loop through each set of empIdList, countriesList
    and find the values individually just to set a flag. In this approach I can’t use
    the TABLE CAST function which is efficient I suppose.
    Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
    suppose to handle large sets of data.
    Thanks In advance
    Regards
    Charan
    Edited by: kmcharan on 03-Dec-2009 09:55
    Edited by: kmcharan on 03-Dec-2009 09:55

    If your query returns results, you have found them... so your "FOUND" flag might be a constant,...

  • Index usage in depending on where clause changes.

    Hello Friends,
    I need your help for one issue.
    I have one query , which is using two table Say T1 and T2, where C1 is common column using which both are joined.
    C1 is primary key in T1, but no index available in T2 for C1. T1C2 is the column which we want to select.
    (Note that Either of table can be a Master table)
    Now see the query:
    Select T1C2
    From T1, T2
    where T2.C1 = T1.C1
    Here where clause may have other conditions and From clause may have others tables as per requirements.
    I want to know that, if, I change the query like following to let my query use the available index of T1.C1.
    Select T1C2
    from T1, T2
    where T1.C1 = T2.C1
    Then, Will the query use the available index of T1. and Will i get better performance. Even a little improvement in performance may help me a lot as this kind of query is being used within a where loop (so it is going to be executed multiple times).
    Please advise on this..
    Regards,
    Dipali..

    Hi,
    18:43:17 rel15_real_p>create table t1(c1 number primary key, c2 number);
    Table created.
    18:43:26 rel15_real_p>create table t2(c1 number, c2 number);
    18:45:08 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t1(c1,c2) values (i,i+100);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    PL/SQL procedure successfully completed.
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t2(c1,c2) values (i,i+200);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    18:45:23 rel15_real_p>select count(*) from t1;
      COUNT(*)
           100
    18:45:30 rel15_real_p>select count(*) from t2;
      COUNT(*)
           100
    18:45:49 rel15_real_p>select index_name,index_type from user_indexes where table
    _name='T1';
    INDEX_NAME                     INDEX_TYPE
    SYS_C0013059                   NORMAL
    18:48:21 rel15_real_p>set autotrace on
    18:52:25 rel15_real_p>Select T1.C2
    18:52:29   2  From T1, T2
    18:52:29   3  where T2.C1 = T1.C1
    18:52:29   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=100 Bytes=
              900)
       1    0   HASH JOIN (Cost=7 Card=100 Bytes=3900)
       2    1     TABLE ACCESS (FULL) OF 'T1' (TABLE) (Cost=3 Card=100 By
              es=2600)
       3    1     TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 By
              es=1300)
    Statistics
              0  recursive calls
              0  db block gets
             21  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            100  rows processed
    18:52:31 rel15_real_p>analyze table t1 compute statistics;
    Table analyzed.
    18:55:35 rel15_real_p>analyze table t2 compute statistics;
    18:55:38 rel15_real_p>set autotrace on
    18:55:42 rel15_real_p>Select T1.C2
    18:55:43   2  From T1, T2
    18:55:45   3  where T2.C1 = T1.C1
    18:55:46   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    Statistics
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed
    18:56:56 rel15_real_p>Select T1.C2
    18:56:56   2  From T1, T2
    18:56:56   3  where T1.C1 = T2.C1
    18:56:58   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    Statistics
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed- Pavan Kumar N

  • Case in where clause

    Hello to everyone
    I have a select like as
    select
              where   (KPMERCE IS NULL AND KSMERCE IS NULL)
         UNION
              where   (KPMERCE IS NOT NULL AND KSMERCE IS NULL AND K_PMERCE = KPMERCE)
         UNION
              where   (KSMERCE IS NOT NULL AND K_PMERCE = KPMERCE AND K_SMERCE = KSMERCE)is possibile create a CASE in where clause, something as, So, i can write a single query,      
              CASE  (in where-clause)
              WHEN   (KPMERCE IS NULL AND KSMERCE IS NULL)                            
              WHEN   (KPMERCE IS NOT NULL AND KSMERCE IS NULL AND K_PMERCE = KPMERCE)
          WHEN   (KPMERCE IS NOT NULL AND KSMERCE IS NOT NULL AND K_PMERCE = KPMERCE AND K_SMERCE = KSMERCE)  so
    IF CONDITION IS SATISFYED RETURNs ROWS OTHERWISE NO ROWS
    Thanks in advance

    If your select lists are equal, then you can do it like this:
    where (  (KPMERCE IS NULL AND KSMERCE IS NULL)
           or (KPMERCE IS NOT NULL AND KSMERCE IS NULL AND K_PMERCE = KPMERCE)
           or (KSMERCE IS NOT NULL AND K_PMERCE = KPMERCE AND K_SMERCE = KSMERCE)
           )Regards,
    Rob.

  • Difference between column_name is null and column_name (+) is null in where clause.

    Hi All,
    I found the below condition in one of the code of my project.
    Select *
    From table name
    Where column_name ( + )  is null .
    Could any one explain what does column_name ( + ) in where clause.
    Thanks in advance.
    Regards,
    Jagadeeah

    Hi,
    Jagadeesh R wrote:
    Hi All,
    I found the below condition in one of the code of my project.
    Select *
    From table name
    Where column_name ( + )  is null .
    Could any one explain what does column_name ( + ) in where clause.
    Thanks in advance.
    Regards,
    Jagadeeah
    The  ( + )  sign is an old way of doing outer joins.  In Oracle 8 and earlier, you couldn't say
    SELECT  *
    FROM             scott.dept  d
    LEFT OUTER JOIN  scott.emp   e   ON  e.deptno  = d.deptno
    Instead, you got those results by saying:
    SELECT  *
    FROM    scott.dept  d
    ,       scott.emp   e
    WHERE   e.deptno  ( + ) = d.deptno
    The 1 line you posted was probably part of a larger WHERE clause.  You'll have a better understanding of what that 1 line is doing if you look at it in context, considering all the join conditions between the tables involved.

  • Passing check box values to WHERE clause

    Hi,
    I have created a Data block - 'CONTACTS' (Database data block)
    and has database item - 'Code', 'Descr'
    The number of records displayed is set to 5.
    Value When checked - 'Y'
    Value When Unchecked - 'N'
    Check box mapping of other values - 'unchecked'
    I am writing the code inside 'WHEN BUTTON PRESSED'. My main objective is to return the count of records based
    based on several conditions and one among them is CODE which is can be single or multiple based on the check box checked.
    The requirement is when i check one or multiple checkboxes, i should pass the 'Code' item values to the WHERE clause.
    Right now whenver i am trying to do so, only the current record value is copied to the WHERE clause.
    I have tried using basic loop but things havnt worked.
    Logic tried with basic LOOP
    BEGIN
    GO_BLOCK('CONTACT');
    IF :contact.cb = 'Y' THEN
    LOOP
    IF p_where is null then
    p_where := :contact.code;
    else
    p_where := p_where ||','||:contact.code;
    end if;
    exit when :system.last_record = 'TRUE';
    next_record;
    END LOOP;
    end if;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;
    And Even if i write the LOOP before the first IF, it return me the current record value and move to the last record.
    please guide me where am i wrong.
    Regards.
    Anoop.

    Try something like this:
    FIRST_RECORD;
    LOOP
      IF :contact.cb = 'Y' THEN
        IF p_where is null then
           p_where := :contact.code;
         else
           p_where := p_where ||','||:contact.code;
         end if;
       END IF;
      exit when :system.last_record = 'TRUE';
      next_record;
    END LOOP;
    -- END LOOP;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;

  • Function in where clause is executed and returns null instead a valid value

    Hi all
    i have a strange problem.
    There is a access-application where i have a pass-through-sql.
    This sql is fetching a foreign exchange rate from a history table which holds this rates for every day and i'm going to fetch the rate for the last day of the last month.
    Example of the fraction which does not work and which i executed directly on the DB, Oracle 11.2.0.3.0:
    select val
    ,last_day(add_months((trunc(sysdate)+3),-1)) tag
    from k.obj_ts_hist th
    where obj_id = 2660
    and eff_date = last_day(add_months((trunc(sysdate)+3),-1))
    --and      eff_date = '01-mar-2013'
    eff_date on table k.obj_ts_hist is defined as date.
    The function last_day in the where clause leads to null for both values in the select (val and tag).
    If i use eff_date = '01-mar-2013' it's all ok, i get the rigth values.
    I tested some combinations of the clause, e.g.
    eff_date = to_date(to_char(last_day(add_months((trunc(sysdate)+3),-1)),'YYYYMMDD'),'YYYYMMDD')
    or
    to_char(eff_date,'YYYYMMDD') = to_char(last_day(add_months((trunc(sysdate)+3),-1)),'YYYYMMDD') , etc., but all of them do not work.
    Also i tested the clause with select ... from dual, e.g.
    select eff_date from
    select last_day(add_months((trunc(sysdate)+3),-1)) eff_date from dual
    where eff_date = last_day(add_months((trunc(sysdate)+3),-1))
    This work's !
    A cross check on Oracle 9.2.0.8.0: it works as expected !
    Thanks in advance for your effort.
    Regards, Konrad

    a little simulation of your formula
    select the_date,last_day(add_months((trunc(the_date) + 3),-1)) eff_date
      from (select to_date('20130224','yyyymmdd') + level - 1 the_date
              from dual
            connect by level <= 7
           )reveals you might have been querrying future rates
    THE_DATE   EFF_DATE 
    24.02.2013 31.01.2013
    25.02.2013 31.01.2013
    26.02.2013 28.02.2013  /* future date */
    27.02.2013 28.02.2013  /* future date */
    28.02.2013 28.02.2013  /* current date */
    01.03.2013 28.02.2013
    02.03.2013 28.02.2013Regards
    Etbin

  • Using a report value for a where clause in other report

    Hi All,
    i'm getting kinda nuts here. I created a page with three reports.
    First report show the name of the user who logged in with his/her whole name. Second report shows the year, week, begin/end date of the week for the user in the first report. The third report show the hours the user worked in the week selected in the second report.
    The link between first and second report is on column report. Somehow i managed it to work with second_report.mdw_code = :P3_ACRONIEM. I have no idea were this P3_ACRONIEM item is coming from, while i have no items in my page whatsoever. Now i need to link the second report to the third report. I have to use the second_report.mdw_code, second_report.year and second_report.week but i have no idea how to link these together. Any idea's? (Like making items, but then i have no idea how to link that item to the value in the second report). Please help.
    Kind regards,
    Dave
    The link between the first and the second i could get it to work with :P3_ACRONIEM. I have no idea where this ITEM is coming from, because i have no items in my page (and it's the only page in the application). Then

    Hi Dave,
    If I understand you correctly, you have a one report that lists users, a second report that lists dates and a final report that shows hours worked?
    If so, you may find it easiest to have hidden fields on your page and base the second and third reports on these using appropriate WHERE clauses. (I generally put hidden fields in a region in the "After Header" position)
    So, if the first report contains a USER_ID field, have a hidden field called P1_USER_ID. The link on the first report will branch back to the same page and set the value of P1_USER_ID to #USER_ID# The second report can then use WHERE USER_ID = :P1_USER_ID. When the page reloads, the second report redisplays and is filtered to show only those records relating to the selected USER_ID in the first report.
    To extend this, if the second report contains WEEK_NUMBER, it should have a link that branches back to the same page and sets a hidden P1_WEEK_NUMBER field with #WEEK_NUMBER#. The third report should when have WHERE WEEK_NUMBER = :P1_WEEK_NUMBER AND USER_ID = :P1_USER_ID. You can, if need be, have and set more than one hidden field during each link.
    Regards
    Andy

  • No output for XML Publisher Report using CASE/DECODE in Where Clause

    Hi,
    I've a business requirement to modify an existing report which has two input parameters,
    -> p_statcode (Closed Status) which can have values 'Y' or 'N'
    -> p_overdue (Overdue Flag) which can have values 'Y' or 'N'
    The Overdue Flag is an evaluated column having values of Y/N and it is evaluated as follows,
    ONTF_MOD_VAL(NVL (
                                         (TRUNC (SYSDATE)
                                          - (TO_DATE (oe_order_lines.attribute18,
                                                      'DD-MON-RRRR')
                                             + TO_NUMBER (fnd_lookup_values.meaning))),
                                         0
                            overdue_flagThe user requirement now is they needs to be a third option for parameter p_overdue called ALL,
    passing which the output should include records having
    p_statcode is Y ELSE p_statcode is N AND p_overdue is Y OR p_overdue is N
    In other words records having both Y and N vlaues for Overdue Flag have to be returned irrespective of the value given to Closed Status.
    Original where clause in the Data Definition file is as follows,
    WHERE Closed_Status = nvl(:p_statcode,Closed_Status)
                       AND overdue_flag = nvl(:p_overdue,overdue_flag)My modified code is as follows,
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = (CASE
             WHEN :p_overdue = 'Y' THEN 'Y'
             WHEN :p_overdue = 'N' THEN 'N'
             ELSE overdue_flag
             END)
    OR
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag)Both approaches have the same problem.
    The output is in EXCEL format. The modified query works fine for p_overdue as Y or N but when p_overdue is passed as ALL it returns an empty EXCEL sheet with just the report output column headers.
    Any help as to why this is the case ?? What is wrong in my approach ?
    Regards,
    Vishal

    not clear about p_overdue = ALL
    which values needed for p_overdue = ALL ?
    try smth like
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL' and (overdue_flag = 'Y' or overdue_flag = 'N')
    )for overdue_flag which has more then 'Y', 'N' values
    if overdue_flag only in ('Y','N') then
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL'
    )

  • How can I pass multiple condition in where clause with the join table?

    Hi:
    I need to collect several inputs at run time, and query the record according to the input.
    How can I pass multiple conditions in where clause with the join table?
    Thanks in advance for any help.
    Regards,
    TD

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • SQL Strings in Where Clause - single quotes issue

    All,
    I’m having issues related to SQL String literals when trying to deploy to flash. The complication works fine but I then get a message (see below) stating that a ; is missing. The SQL query and the iview runs fine when we use numeric values or do not apply a where clause on the table.
    I am using Visual Composer that has been packaged with NW2004sSP7_Preview
    VC & Flex Version: 645.7.0.3
    The Error message is get is;
    Error in executing a process for Flex compilation, Error 1033: ';' expected
          (C:usrsapJ2EJC01j2eeclusterserver0GUIMachine_Business_Packagestest_48731FLEX_COMPILATION_FOLEDRAADCN.mxml:269)
    Error 1205: The statement 'Test' is incomplete.
          (C:usrsapJ2EJC01j2eeclusterserver0GUIMachine_Business_Packagestest_48731FLEX_COMPILATION_FOLEDRAADCN.mxml:269)
    Failed to compile AADCN.mxml
    When I goto the deployment file – it has the below line;
    <i>'<Request type="EXECUTE_RELATIONAL" system="BI_JDBC" system_type="SAP_BI_JDBC" maxrows="500" templateid="BIR_SQL"><Objects type="INPUT" shape="OBJ" role="INPUT"><Object type="INPUT_FIELD" id="SQL_STATEMENT" appName="SQL" mapped="0" value=""/></Objects><Objects type="OUTPUT" shape="SET" role="OUTPUT"><Object type="OUTPUT_FIELD" id="name" appName="name"/></Objects><Objects id="1" type="TEMPLATE_PARAMETER"><Object id="2" type="SQL" value="select name from pub.srcompany where name ='Test Company'"/></Objects></Request>';</i>
    It seems that the parser for the flash deployment is prematurely finishing the parse when it hits the single quotation in the SQL string!
    We had a similar error where if we had a carriage return in the SQL (e.g. between the from & the where clause) then the deployment parser was stating that the line finished prematurely. In the deployment file the carriage return forced a new line thus making the message incomplete. Removing the carriage return resolve that issue
    The SQL Preview in the SQL Editor within VC works fine with the string literals in the where clause.
    The functionality compiles & deploys in web dynpro however it does not return the results to the table
    Questions
    1:> Has anyone successfully used flash with string literals in the SQL where clause or had seen this issue in the past?
    2:> Is there a setting to get the SQL working on Web dynpro for the information to be returned that I may have missed?
    Any assistance would be greatly appreciated.
    Best Regards,
    Ian.

    Hey,
    I have worked with SQL Editor a lot. Here's a how to guide I put together on it:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6339e7d4-0a01-0010-1c98-db00e52e989a
    Let me know if that helps...
    Prakash

  • Dynamic query in where clause while looping in an internal table.

    Hi,
    Had a small question : How can i make a dynamic query for the WHERE clause while looping at an internal table.
    i want to implement a dynamic where clause query for the below example.
    it_cfx_col is an internal table and wa_cfx_col is a work area for it_cfx_col
      DATA :
      i_cfx_col TYPE TABLE OF cfx_col,
      wa_cfx_col LIKE LINE OF i_cfx_col.
    DATA : count TYPE i VALUE 0.
    DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
    LOOP AT it_cfx_col INTO wa_cfx_col
    WHERE CREATED_BY = l_name
    AND SCENARIO = l_scenario.
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    Now i want to write a dynamic query for the where clause.
    DATA : count TYPE i VALUE 0.
      DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
      l_where_clause = 'CREATED_BY = l_name'.
      l_where_clause2 = 'AND SCENARIO = l_scenario'.
    if l_scenario is not initial.
      CONCATENATE  l_where_clause l_where_clause2
      INTO l_where_clause SEPARATED BY space.
    endif.
    LOOP AT i_cfx_col INTO wa_cfx_col
    WHERE (l_where_clause).
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    when i compile this i get an error message as { Statement concluding with "...(l_where_clause)" ended unexpectedly}
    Even i changed the initilization of the variable  l_where_clause2 to [ l_where_clause2 = 'AND SCENARIO = l_scenario.'. ]
    added the end of line demarkation ".", but still i got the same error message.
    Is it a limtation in ABAP that i cannot write a dynamic query for the where clause while looping at an internal table?
    Regards,
    om

    Hi savita,
    there in no such 1 limitaion in abap for dynamic query .. i think the  error meassge is only beacuse of your synatx delcartaion.
    >> LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE (l_where_clause).
       count = count + 1.
    some business logic implemented using the work     area    wa_cfx_col
       endloop.
    afted delclarataion also , in the where statement you should specify both the field name and value bname
       LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE l_where_clause = 'CREATED_BY = l_name' .
       count = count + 1.
    hope it helps.
    regads
    priya.

  • Passing a value to Inline View  WHERE clause through JDev...

    Hi ,
    I need to pass a value to inline view which is mentioned in below VIEW query.
    That view is created inside a view using jDev. Note that there are two WHERE clauses one in the Main query and the other in the Inline view.
    How to set the value for the innerView.
    //copied the code from Java
    view.volAlertsHistroyView.setWhereClauseParam(1, new Integer(clientId));
    Gives an error Missing IN or OUT parameter at index:: 1
    SELECT Alerts.SEND_TIME,
         Alerts.STATUS,
         Alerts.TEXT ,
         Groups.NAME,
              VolRoles.ROLE_NAME,
                   VolRoles.ID as vid,
                   Groups.ID as gid
         FROM ALERTS Alerts, ALERTS_GROUPS AlertsGroups, GROUPS Groups, VOL_ROLES VolRoles,
    --Inline view starts
    (SELECT GRP_ID, VRL_ID FROM vol_groups WHERE cli_id = :1) user_group_role
    --Inline view ends
    --Actual WHERE clause starts
         WHERE ((Alerts.ID = AlertsGroups.ALT_ID)AND (AlertsGroups.GRP_ID = Groups.ID))AND (AlertsGroups.VRL_ID = VolRoles.ID)
         AND AlertsGroups.VRL_ID = user_group_role.VRL_ID AND AlertsGroups.GRP_ID = user_group_role.GRP_ID
    Please get back to me .
    Regards
    Mohan
    [email protected]

    What happens when you change your Java code to:
    view.volAlertsHistroyView.setWhereClauseParam(0, new Integer(clientId));
    The ":1" does not directly relate to the where clause param index you use in Java. In your query you could also use a ":2" for example. In BC4J you still use "0" for the first param.
    Sascha

  • How to retrieve the 'Where Clause' text?

    Hello all,
    I have created a package to retrieve all the DML's executed against the database for the day, for a particular user. DBMS_LOGMNR package was used to retrieve DMLs. But the DMLs retrieved have their 'WHERE' clause text converted to ROWID's. I need to find out the 'WHERE' clause with the parameters.
    I tried retrieving values from the v$sql views, but that information is cryptic and very volatile.
    Is there a way to retrieve the 'Where' clause? If not, is there a way to retrieve the 'WHERE' clause information using a trigger against the corresponding table.
    I am desparately lookin'for a solution. Hope someone out there can help me out.
    Regards,
    Prabu Raghav.

    Hi Andrew,
    Thanks for the suggestion.
    I am using Oracle 8i not 9i.FGA using DBMS_RLS let's me add policies and retrieve all other information about a user except the SQL statement that's executed by the user.
    I want to retrieve the Current sql statement executed against the table by a particular user and record it.
    Any suggestions?
    Regards,
    Prabu Raghav.

Maybe you are looking for