Select Statement -- Where Clause Execution Order

What is the order of execution of the "AND" and "OR" in the WHERE clause of a Select statement?
Are the "AND"'s executed from the top down, left to right? Is it the same for the "OR"'s execution?
Thanks for any help...

Not clear why you care. There is an order in which the optimizer parses the SQL (which may change from ver to ver), but this is a fairly quick operation. The order in which tables are visited and predicates evaluated is dependent on what the op[timizer does with the SQL.
Ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Offset operation in select statements where clause

    dear experts,
        if i use offset operation in select query , syntactically giving
        me a warning message.
        how to avoid warning message
        without using another internal table populated with  only  jtab+0(10).  
       ex:
              select field1 field2
                        into table   itab
                        from ztable1
                        for all entries in jtab
                        where field =  jtab+0(10).
    thanks in advance.

    No need to populate another internal table...
    when populating jtab from database select ur field twice
    structure for jtab..
    types: begin of ty_jtab,
              field type ...
              field1 type char10,
            end of ty_jtab.
    populate the field twice..
       select ...
                 field
                 field
    into table jtab
    Now u can use the field field1 in the next select
    select field1 field2
    into table itab
    from ztable1
    for all entries in jtab
    where field = jtab-field1.

  • Is it possible to use LONG columns in WHERE clause or ORDER BY?

    Is it possible to use LONG columns in WHERE clause or ORDER BY?

    Hi,
    LONG data type is deprecated, maybe could you change your column type to LOB ?
    Nonetheless below is a workaround which may fit your needs if forced to use LONG.
    It uses a function which returns you a CLOB. It allows you to use the converted "LONG" column in a WHERE clause.
    Then if you want to order by you have to convert the CLOB to a VARCHAR using DBMS_LOB.SUBSTR.
    SQL> CREATE TABLE my_table (id NUMBER, description LONG);
    Table created.
    SQL> INSERT INTO my_table VALUES (1, 'FIRST LONG');
    1 row created.
    SQL> INSERT INTO my_table VALUES (2, 'ANOTHER LONG');
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> CREATE TYPE my_type_row AS OBJECT (id INTEGER, description CLOB);
      2  /
    Type created.
    SQL> CREATE TYPE my_type_table AS TABLE OF my_type_row;
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION get_my_long
      2     RETURN my_type_table
      3     PIPELINED
      4  AS
      5     v_tab   my_type_table := my_type_table ();
      6  BEGIN
      7    FOR cur IN (SELECT id, description FROM my_table)
      8  LOOP
      9        PIPE ROW (my_type_row (cur.id, cur.description));
    10  END LOOP;
    11  RETURN;
    12  END;
    13  /
    Function created.
    SQL> SELECT
      2     id,
      3     description
      4  FROM
      5     TABLE (get_my_long ())
      6  WHERE
      7     description LIKE '%LONG'
      8  ORDER BY
      9     DBMS_LOB.SUBSTR(description);
      ID DESCRIPTION
       2 ANOTHER LONG
       1 FIRST LONG
    SQL> SELECT
      2     id,
      3     description
      4  FROM
      5     TABLE (get_my_long ())
      6  WHERE
      7     description LIKE 'FI%';
      ID DESCRIPTION
       1 FIRST LONG
    SQL>Kind regards,
    Ludovic

  • Where clause and order by to DAO classes

    Hi
    Is it ok(I mean design wise) to pass the 'where clause' conditions and order by clause as a parameter to the method of DAO class?

    Well, I would suggest you write seperate methods in your dao , one to select data without the where clause and one to select data with the where clause thrown in. If you have different 'where' clauses for selecting different kinds of data, have that many dao methods. The dao methods being specific know exactly what is the data that's coming in.
    Lets assume you have a list of purchase orders and each purchase order is indetified by a unique id called PURCHASE_ORDER_ID.
    1. The following code would populate a purchase order's details given an id.
    private statis final String QUERY_1 = "select * from PURCHASE_ORDERS where PURCHASE_ORDER_ID = ? ";
    PurchaseOrderModel getPurchaseOrderData(long poId){
         //get a prepared statement from your connection
         PreparedStatement pst = conn.prepareStatement(QUERY_1);
         //set the poId passed as params to your query
         pst.setLong(1, poId);
         ResultSet rs = pst.executeQuery();
         if(rs.next()){
              //populate data into a model          
         finally{
              //clean up resources
         return model;    
    }2. The following code would return a list of PurchaseOrderModel's whose shipping date falls between a set of dates selected by the user.
    private statis final String QUERY_2 = "select * from PURCHASE_ORDERS where SHIPPING_DATE between ? and ? ";
    PurchaseOrderModel getPurchaseOrdersBetweenDates(list bindValues){
         //get a prepared statement from your connection
         PreparedStatement pst = conn.prepareStatement(QUERY_1);
         //set the dates passed as params to your query
         //we know that the List ought to contain only 2 dates
         pst.setDate(1, (Date)bindValues.get(0));
         pst.setDate(2, (Date)bindValues.get(1));
         ResultSet rs = pst.executeQuery();
         if(rs.next()){
              //iterate and populate data into a model          
              //add model to a list
         finally{
              //clean up resources
         return list;    
         3. This is more interesting - the dao method searches a list of Purchase Orders starting with a set of specific words. The words themselves may be one or many. This means that the number of '?' in your prepared statement may be dynamic. Each element of the list is a String that contains the start substring of a purcahse order name. For example - the list may contain elements like ["a", "ab", "c", "gh"] and the dao method returns all purchase order starting with these names.
    private statis final String QUERY_3 = "select * from PURCHASE_ORDERS where ";
    PurchaseOrderModel getPurchaseOrderNameMatches(list bindValues){
         //construct the query dynamically
         StringBuffer query = new StringBuffer(QUERY_3);
         int count = 0;
         for(Iterator itr = bindValues.iterator(); itr.hasNext();;){
              String value = (String)itr.next();
              query.append ("name like 'value%' ");
              if (count != 0 and (count+1 != bindValues.length)){
                   query.append(" or ");
              count ++;          
         //get a prepared statement from your connection
         PreparedStatement pst = conn.prepareStatement(query.toString());     
         ResultSet rs = pst.executeQuery();
         if(rs.next()){
              //iterate and populate data into a model          
              //add model to a list
         finally{
              //clean up resources
         return list;    
    To sum up,
    1. You need as many methods as you have different kinds of searches (one method for each kind of 'where' clause).
    2. The ejb/business layer would examine the data and decide on which method to call.
    3. Increases coding effort, but makes the code clean and readable. Each layer does it's job. Thus we dont have ejbs forming 'where' clauses and so on.
    Having said that, it really is your decision - you should take into consideration the following factors -
    1. How big is the project ? If its a huge codebase developed by many people, then segregate the responsibilities clearly in each layer as I have outlined. For a small scale project, you could go with your approach.
    2. Whats the take on maintenance and future add-ons ? Do you see the codebase growing with time ?
    3. Is your project a commercial one - is it a product that needs to be maintained or is it a one-off development - develop once and you are done with it.
    4. What are the design considerations ? Is somebody going to audit code for quality ? Or is it a academic one ?
    You should take into account all these before deciding to go one way or the other.
    A general thumb rule should be that you should be convinced that your code readable (maintainable), scalable and efficient. Anything that you do towards these ends is good code/design despite what people/books/patterns say, IMO.
    cheers,
    ram.

  • SELECT with WHERE clause for MSAccess from JDBC

    Hi,
    I am new user of MSAccess.I am getting exception: Invalid user type when i was trying the following code:
    String name1=nameTextfield.getText().trim();
    String query="SELECT ID from Suppliers WHERE name=name1;"
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery(query);
    while(rs.next())
    String id1=rs.getInt(1);
    System.out.println(id1);
    nameTextField is JTextField in my GUI.
    ID id auto field in table Suppliers.
    I am using MSAccess 97.
    I came to know that the JDBC SQL queries will be different for Access.
    Any body help me how to write SELECT statement?
    Thanks in advance,
    Sai Ram

    name or ID might be reserved words in access. Either change the name of the column or put [] around them. Also, you ar looking for a record where fields name and name1 are equal. You probably don't have a name1 field.
    String name1=nameTextfield.getText().trim();
    String query="SELECT [ID] from Suppliers WHERE [name]='"+name1+"';"
    Pay attention to the single and double quotes I have.

  • Select statment - where clause

    Hello experts,
    I want to write a select statment,
    e.g.
    select * from pa0001 where ename like '%Rahul%'.
    so this stamemt will give me all DB rows in which ename contains Rahul but i also want rows those are having rahul or rAhul or raHul or RAhul or RAHul or RaHul like wise....
    can u plz help me on this ???

    Hi
    Find the below code which may be useful for your requirement
    ranges:r_sel for lfa1-name1.
    data:v_name(5) type c value 'laxmi'.
    data:len type i,
    v_num type i,
    v_num1 type i,
    v_num2 type i,
    v_name1(5) type c,
    v_name2(5) type c,
    v_name_final(7) type c,
    v_char type c.
    len = strlen( v_name ).
    clear:v_name1,v_name2,v_name_final,v_num,v_num1,v_num2.
    v_num1 = len.
    do len times.
      v_num1 = v_num1 - 1.
      v_char = v_name+v_num(1).
      v_num2 = v_num.
      v_num = v_num + 1.
      if v_num1 is initial.
        clear:v_name1.
      else.
        v_name1 = v_name+v_num(v_num1).
      endif.
      if v_num2 is not initial.
        v_name2 = v_name+0(v_num2).
      endif.
      translate v_char to upper case.
      concatenate '' v_name2 v_char v_name1 '' into v_name_final.
      r_sel-option =  'CP'.
      r_sel-sign = 'I'.
      r_sel-low = v_name_final.
      clear:r_sel-high.
      append r_sel.
      translate v_char to lower case.
      concatenate '' v_name2 v_char v_name1 '' into v_name_final.
      r_sel-option =  'CP'.
      r_sel-sign = 'I'.
      r_sel-low = v_name_final.
      clear:r_sel-high.
      append r_sel.
    enddo.
    Use range parameter in your select statement.
    Regards
    Sripal

  • Select and where clause

    Hi
    I want to write a select statement and in where condition
    1.I want to retrieve the fields which contains a string 'ABAP'
    2.I want to retreive the fields which is equal to space.
    eg;
    SELECT FLD1 FLD2 FLD3 FROM TABLE1 WHERE
       WHERE
       fld1 contains string 'ABAP'
    and fld2 is equal to space.

    Hi
    Yes you can, but you should use the language in the selection on MAKT:
    SELECT MARA~MATNR
    MAKT~MAKTX
    MCH1~CHARG
    MCH1~VFDAT INTO CORRESPONDING FIELDS OF TABLE GT_MATERIALS
    FROM MARA
    INNER JOIN MAKT
    ON MARAMATNR = MAKTMATNR
    INNER JOIN MCH1
    ON MAKTMATNR = MCH1MATNR
    INNER JOIN MVKE
    ON MVKEMATNR = MAKTMATNR
    WHERE MARA~MTART = 'ZDRU'
    AND MARA~LVORM = SPACE
    <b>  AND MAKT~MAKTG LIKE '%DISCONTINUE%'
      AND MAKT~SPRAS  = SY-LANGU "or EN</b>
    AND MVKE~VKORG = 'PUSA'
    AND MVKE~VTWEG = 'SPART'
    AND MVKE~MVGR4 = 92
    AND MCH1~CHARG IN S_CHARG.
    Max

  • Select avoiding where clause

    Hello,
    I am using JPA in my app and I am confused because of a select that is returning data as I didn't have anything in my where clause.
    Select A (with problems):
    Query q = em.createQuery(
    " Select distinct p "+
    " From Subgrupo sub,"+
    " UsuarioSubgrupo usb," +
    " Usuario u, "+
    " Grupo g, "+
    " Projeto p "+
    " where "+
    " sub.cdGrupo = g.cdGrupo and "+
    " g.cdProje = p.cdProje and "+
    " g.stAdmin = 1 and " +
    " sub.cdSubgr = usb.cdSubgr and " +
    " usb.cdUsuar = u.cdUsuar and " +
    " u.cdUsuar = 1"
    Select B (almost OK):
    Query q = em.createQuery(
    " Select p.dsProje "+ // the only difference
    " From Subgrupo sub,"+
    " UsuarioSubgrupo usb," +
    " Usuario u, "+
    " Grupo g, "+
    " Projeto p "+
    " where "+
    " sub.cdGrupo = g.cdGrupo and "+
    " g.cdProje = p.cdProje and "+
    " g.stAdmin = 1 and " +
    " sub.cdSubgr = usb.cdSubgr and " +
    " usb.cdUsuar = u.cdUsuar and " +
    " u.cdUsuar = 1"
    In the second select, I've got the rows according with where clause and I cannot understand how the fact of selecting an objetc Projeto (p) (select A) can make such a "mess" avoiding the rules of the where clause.
    Could someone give me a help about this problem?
    I'll be glad with any help!!
    []'s
    Alex
    !_Let's share ideas_!

    Hi,
    The issue is I am getting differents results from selects A and B and both have the same where clause.
    I have done this:
    Query q = em.createQuery(
    " SELECT NEW entity.Projeto (p.dsProje, p.cdProje) "+
    " From Subgrupo sub, "+
    " UsuarioSubgrupo usb," +
    " Usuario u, "+
    " Grupo g, "+
    " Projeto p "+
    " where sub.cdGrupo = g.cdGrupo "+
    " and g.cdProje = p.cdProje "+
    " and g.stAdmin = 1 "+
    " and sub.cdSubgr = usb.cdSubgr "+
    " and usb.cdUsuar = u.cdUsuar "+
    " and u.cdUsuar = " + cdUsuar
    I am getting what I need, but the reason why a simple select p does not work I don't know.
    This select is not generate by TopLink.
    Cheers!

  • PL/SQL: how to use in parameter in select sql where clause

    Hi
    in a procedure, I need to apply 'in parameter' in 'where clause' along with other table fields. Purpose is to create dynamic select querry with multiple conditions.
    select count(*) from table xx
    where y_code=2008 and v_type in ('SI', 'TI', 'DI') ;
    my requirement is replace 'and v_type in ('SI', 'TI', 'DI')' with in parameter. pls note in paramter may contain null value.
    Regards

    ... e.g. why on earth do you want to pass in a string to be appended to the WHERE clause of an SQL.I second that and I strongly advice NOT to do it. If you really want to do it, then come back and show us, how you would prevent SQL injection. This approach is too dangerous (and too complex) IMHO.
    Do it straight forward as in the article of Tom Kyte (link in the post of BluShadow above)

  • Avoid repeating same logic in 'select' and 'where' clauses?

    I'll preface by saying I'm self-taught and have only been fiddling with SQL for a couple of months, so forgive me if this is a dumb question. I have a query written to pull out customers who are configured to have their products stored at the wrong warehouse, according to the first 3 digits of the zip code. Here is an extremely simplified version of a query I'm trying to run:
    select custno, custbuy_zip_cd, custbuy_prim_ship_loc_cd as Warehouse,
    case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end as StdWhse
    from customers
    where case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end <> custbuy_prim_ship_loc_cd
    or (case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end is not null and custbuy_prim_ship_loc_cd is null)
    Now, the query works, but it seems overly convoluted and feels like there must be a way to make it simpler and faster. I'm using the same 'case when' 3 times. Originally, I had thought I could use the aliases from the 'select' clause in the 'where' clause, which would simplify things:
    select custno, custbuy_prim_ship_loc_cd as Warehouse,
    case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end as StdWhse
    from customers
    where StdWhse <> custbuy_prim_ship_loc_cd
    or (StdWhse is not null and custbuy_prim_ship_loc_cd is null)
    I then found out that that caused 'invalid identifier' errors. My first attempt at a solution was to use a subquery in the 'from' clause, but that ran the 'case when' on every single customer instead of the small subset, so it wound up taking much longer even though it looked neater. Any tips on how to clean up that first query to make it run faster?
    this is Oracle 11i, I believe. As a side note, I don't have write access to the database.

    Thanks for all the tips so far - still going through them. You all respond fast! Sorry about using double angle brackets for != and not using code tags, I'll make sure to format my posts properly going forward. I think the double angle brackets messed up the appearance of my original queries a little. Here's how I probably should have pasted my first query in my first post:
    select custno, custbuy_zip_cd, custbuy_prim_ship_loc_cd as Warehouse,
        case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
            when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
        end as StdWhse
    from customers
    where case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
            when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
        end != custbuy_prim_ship_loc_cd
        or (case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
            when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
        end is not null and custbuy_prim_ship_loc_cd is null)The almost unanimous opinion seems to be that I should use a subquery in one way or another, but the problem remains that the only significant logic to narrow down the results is the logic that matches the 'case when' results (which are what the warehouse number should be, based on the zip code) to the current warehouse number. Therefore, it seems like any subquery is going to return my entire list of 600k customers, and take a much longer time than my original (messy) query. At least it has in the test runs I created based on
    Satyaki's and Peter's examples. The query based on my original example takes about 2.5 minutes, and the subquery examples take about 5+ even though they look cleaner.
    to clarify what the query is trying to accomplish, I want it to pull any records where the warehouse number does not equal the correct warehouse number based on zip code (or if the warehouse number is null when it shouldn't be).
    I'll try to create some sample data and sample results. Customers table:
    custno   custbuy_zip_cd  custbuy_prim_ship_loc_cd
    1        59024           20
    2        59024           33desired results:
    custno   custbuy_zip_cd   warehouse   StdWhse
    1        59024            20          33If I could create a table to hold the standard warehouses to join on, the whole thing would be much easier. The full version of the query really has hundreds of zip code prefixes and 5 different warehouses and each account has 4 alternate warehouses as well. However, I'm stuck with read only access so everything has to go right in the query. It wouldn't be the end of the world to just stick with my original query since it's not like it takes hours, and I'll only be running it weekly. I just wanted to make sure there wasn't some other solution that wasn't just cleaner but was also faster.

  • Regarding Select without Where clause

    Hi
    we have below code for F4HELP on invoice input field.
    you can see Select statement used without Where condition to fetch records from Ztable.
    and deleting the duplicating records.
    SCI error says,"Large table : it has no where condition. /No field of a table index in WHERE condition.
    Is this potential problem?
    How to handle this generally? does where condtion is must to use in Select statement.?
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_ZIVCNO-LOW.
    * Search help setting of uFF62Invoice numberuFF63
      PERFORM F_F4HELP_RSTYP CHANGING S_ZIVCNO-LOW.
    FORM F_F4HELP_RSTYP  CHANGING C_V_INVCNO TYPE ZGTSDE_ZIVCNO."Invoice number
      DATA:
    *   Work area for Return the selected value
        WL_F4RETURN  TYPE DDSHRETVAL,
    *   Internal table for Return the selected value
        TL_F4RETURN  TYPE STANDARD TABLE OF DDSHRETVAL,
    *   Internal table for Processing result
        TL_INVOICE   TYPE TABLE OF TYP_INVOICE.
      SELECT ZIVCNO
      FROM   ZGTSDT01
      INTO   TABLE TL_INVOICE.
      CHECK TL_INVOICE[] IS NOT INITIAL.
      DELETE ADJACENT DUPLICATES FROM TL_INVOICE.
    *  Search help is started
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          RETFIELD        = CG_FIELD_INVCNO   " Packing No
          VALUE_ORG       = CG_VALUE_S       " Value return
        TABLES
          VALUE_TAB       = TL_INVOICE       " Table of values
          RETURN_TAB      = TL_F4RETURN      " Return the selected value
        EXCEPTIONS
          PARAMETER_ERROR = 1
          NO_VALUES_FOUND = 2
          OTHERS          = 3.

    Since your F4 help on your selection-screen is independent, create a custom search help as suggested by Keshav.
    As a suggestion Instead of,
    SELECT ZIVCNO
      FROM   ZGTSDT01
      INTO   TABLE TL_INVOICE.
      CHECK TL_INVOICE[] IS NOT INITIAL.
      DELETE ADJACENT DUPLICATES FROM TL_INVOICE.
    use,
    SELECT DISTINCT(ZIVCNO)
      FROM   ZGTSDT01
      INTO   TABLE TL_INVOICE.
    BR,
    Suhas

  • Dynamic page with multiple select in where clause

    Hi,
    I have a dynamic page and in the where-clause, i have a bind variable. In a report i use for instance
    and rtrim((to_char(date_time5,'DAY'))) IN :v_day
    That works ok in a report. But it does not work in a dynamic page.
    what code is needed to work with a multiple select box on the customize screen for a dynamic page?
    Thanks.

    Hi.
    I have a dynamic page, with a bind variable :v_day. On the customization screen the user can select one or more days of the week, or all days. I use this also in a report and then it works ok. In the where clause i use:
    and rtrim((to_char(date_time,'DAY'))) IN :v_day
    Date_time is a tablecolumn (date).
    When i add this line in the select script from the dynamic page, i get error:
    : ORA-06550: line 1, column 2443:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    The symbol "(" was substituted for "" to continue.
    ORA-06550: line 1, column 2606:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    . ( ) , * @ % & - + / at mod rem <an exponent (**)> and or ||
    The symbol ")" was substituted for ";" to continue.
    ORA-06550: line 1, column 3236:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    The symbol (WWV-11230)
    Critical Error in wwerr_api_error.get_errors! SQL Error Message: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-)
    Thanks.

  • Mysql select statement where = works and LIKE fails

    I am using Flash Builder 4. On the server side I use php and mysql. I created a php dataservice using FB4. My plan had been to allow users to enter a search term and query the database using a "LIKE" statement. FB4 created the php code that I simply modified changing the parameter name. The input parameter is a string.
    public function getT_caseByID($searchTerm) {
    $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename WHERE (title = ?)");
    $this->throwExceptionOnError();
    mysqli_stmt_bind_param($stmt, 'i', $searchTerm);
    $this->throwExceptionOnError();
    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();
    mysqli_stmt_bind_result($stmt, $row->idt_case, $row->title, $row->id_author, $row->comments);
    if(mysqli_stmt_fetch($stmt)) {
          return $row;
    } else {
          return null;
    A look at FB4 shows this code returns data.
    This code works fine but if I make the below change it fails, even when I use the wildcard %. the only change is "=" to "LIKE".
    public function getT_caseByID($searchTerm) {
    $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename WHERE (title LIKE ?)");
    $this->throwExceptionOnError();
    mysqli_stmt_bind_param($stmt, 'i', $searchTerm);
    $this->throwExceptionOnError();
    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();
    mysqli_stmt_bind_result($stmt, $row->idt_case, $row->title, $row->id_author, $row->comments);
    if(mysqli_stmt_fetch($stmt)) {
         return $row;
    } else {
         return null;
    A look into FB4 shows "void".
    Any help would be appreciated. I am using localhost on Apache Server on a development computer with Windows XP.

    correctio0n on the select statement
    select statement code*********
    select
        apspnr astspr aobjnr apspid
        bpsphi bposid
        caufnr cpspel
        dinact dstat
        eudate eusnam eutime "estat
       F~TXT04
        g~estat
        G~TXT04
        into corresponding fields of table itobj
        from proj as a
        inner join prps as b on apspnr = bpsphi
        inner join aufk as c on bpspnr = cpspel
        inner join jest as d on cobjnr = dobjnr
        inner join jcds as e on dobjnr = eobjnr
                             and dstat = estat
        inner join tj02t as f on estat = fistat
        inner join tj30t as g on astspr = gstsma
        for all entries in itparm
        where  apspid = itparm-pspid "or estat = itparm-psy )
        or  bposid = itparm-posid "or estat = itparm-wsy )
        or  caufnr = itparm-aufnr "or estat = itparm-nsy  )
        and ( dinact  'X' or einact  'X')
        and fspras = 'E' and gspras = 'E'.

  • Select statement - Where Condition not possible

    Hi,
    I am trying to extract data from sap standard table CFX_COL.I want extract based on a field which is of type string.I can see that in the table but when I code below I am getting error.Any other alterantives?
    REPORT x.
    TABLES:proj.
    DATA: it_proj TYPE STANDARD TABLE OF proj.
    DATA:wa_proj TYPE  proj.
    DATA: it_cfol TYPE STANDARD TABLE OF CFX_COL.
    DATA:wa_cfol TYPE  CFX_COL.
    data:v_name type STRING.
    PARAMETERS: p_pspid LIKE proj-pspid.
    SELECT * FROM proj INTO CORRESPONDING FIELDS OF TABLE it_proj
    WHERE pspid = p_pspid.
    READ TABLE it_proj INTO wa_proj INDEX 1.
    concatenate wa_proj-pspid '-' wa_proj-post1 into v_name.
    select * from CFX_COL into CORRESPONDING FIELDS OF TABLE it_cfol
    where name in v_name.
    Error:The Field "NAME"  is a long string , so it cannot be used in WHERE, ON or HAVING conditions.
    Rgds
    Vara

    Hi Vara.
    Select will not work if you are trying to search based on the name field as in the table  CFX_COL it has data type String which basically is not content but a reference to a storage area and internally it is stored in a different format not searchable. Even , if you try to find the number of entries in the table you can not put any value in this field as it will not be available for input as it doesn't contain any value.
    STRING: Character string with variable length This data type can only be used in types (data elements, structures, table types) and domains. In the Dictionary a length can be specified for this type (at least 256 characters). It may be used in database tables, however, only with restrictions. For a description of them refer to the documentation of the ABAP statement 'STRING' . In ABAP, this type is implemented as a reference to a storage area of variable size. As default for the output length 132 characters are proposed. You cannot attach search helps to components of this type.
    http://help.sap.com/saphelp_40b/helpdata/en/cf/21f2e5446011d189700000e8322d00/content.htm
    Regards
    Apoorva

  • Select statements where we have to write in crm 7.0

    hi
    i am new to sap crm 7.0
    1)where we are useing select statments in sap crm 7.0
    where we have to write the code as a crm technical consultant
    at which level genil or bol .if we write can u plz let me knw with clear answer.

    Subhani,
    Writing queries in CRM is always tricky. The question you have asked is very general, still i will try my hands on it for the larger benefit of the community.
    One should avoid writing queries on UI layer - As a general practice writing queries on UI is not appreciated because it hampers performance to a large extent.
    Use of standard FM instead of queries - There are several standard FM provided by SAP which serves most of the purpose for which queries may have to be written, they are written in a way so as to optimize the DB connect.
    BOL/GenIL - Incase the interaction with the DB table is very frequent, Query must be written in BOL/GenIL layer, this is done in order to have a steady framework and avoid frequent DB connect.
    If you have any specific query, feel free to post it but be more elaborative so that community members can help.
    Regards,
    Harshit Kumar

Maybe you are looking for

  • Links to open PDF not working in WebHelp RH TCS3

    In my FM files I want to create links to open a pdf file (ideally at named destinations, but that seems a distant dream ) In RoboHelp I have included the PDF in my baggage folder (in it's own folder, called PDF) My Go to URL link in FM is: message UR

  • URGENT: How to add an URL link to an Image?

    Hi, I need to be able to link a web page from an image . How can I do this using Oracle Portal? Many THANKS Mariela

  • How do I restore my iPod?

    I have locked myself out of my ipod by forgetting my passcode, how do i restore this ipod from a new computer

  • Time management

    Hi Gurus, I am trying to understand Time management concepts, pls help me on the following - 1) what is factory calendar, and special rules in factory calendar, and how is it different from holiday calendar.Is factory calendar applicable only to fact

  • Database contains stale optimizer statistics

    I am upgrading from oracle 9.2.0.7 to 10.2.0.3 , During inital stages I get the following warning message "WARNING: --> Database contains stale optimizer statistics. .... Refer to the 10g Upgrade Guide for instructions to update" .How can I handle th