Select statement on unique key consraint

I have a table 'PO' in which 'ID' is primary key and 'PO_NUM' is unique key. I am using a select statement on unique key 'PO_NUM' to get the 'ID'.
select id from po where po_num= '3266';
it says, 'no data found'
But the exists in the database. Can anyone help me with this one.
Thanks
-Lavanya

Is "no data found" an "in-house" error message, i.e. one you put out in a print statement in a catch block? If so, change that catch block to include a stacktrace so we can see what the actual error message is, if there is one, or if it is actually returning an empty result set.

Similar Messages

  • Select statement for primary keys

    Hi
    What is the syntax to select a statement from a table with only primary keys. there are 4 primary keys i have to select all the 4 primary keys is there any syntax difference???

    Hi,
    do u want those primary keys in the internal table or else will u have a where condition based on those all the primary key fields
    if u use all the four primary keys u can write like this remember one thing first u write the field just like in the table created order it is not mandatory to do like that but it increases the performance of the so query
    select single * from ztable into table t_tab where (mention all the four primary keys here ) it increases the performance we are using this single because u r giving all the primary keys in the select query so obvously one record will be there so it increases the query performance..
    if wont give those primary keys then write like this select * from ztable into table t_tab.
    as normal as ordinary
    i hope u got cleared
    plzz reward if it is helpful..
    plzz dont forget to reward...

  • How to do an insert with a select statement, with unique values

    Hi,
    I have an insert statement like this
    INSERT INTO TABLEA (ID, zzz
    SELECT sequence.nextval, zzz FROM TABLEB
    The problem is TABLEA won't allow any duplicates and TABLEB will return duplicates. Yet I can't use the distinct keyword since I am using a sequence.
    Thanks.

    Samuel411 wrote:
    Hi,
    I have an insert statement like this
    INSERT INTO TABLEA (ID, zzz
    SELECT sequence.nextval, zzz FROM TABLEB
    The problem is TABLEA won't allow any duplicates and TABLEB will return duplicates. Yet I can't use the distinct keyword since I am using a sequence.
    Thanks.Why not?
    drop sequence s
    create sequence s;
    create table distincting (col1 number, object_owner varchar2(30));
    TUBBY_TUBBZ?
    insert into distincting
    select s.nextval, object_owner
    from
      select
        distinct
          owner as object_owner
      from dba_objects
      9  );
    37 rows created.
    TUBBY_TUBBZ?

  • How to get the inserted row primary key with out  using select statement

    how to return the primary key of inserted row ,with out using select statement
    Edited by: 849614 on Apr 4, 2011 6:13 AM

    yes thanks to all ,who helped me .its working fine
    getGeneratedKeys
    String hh = "INSERT INTO DIPOFFERTE (DIPOFFERTEID,AUDITUSERIDMODIFIED)VALUES(DIPOFFERTE_SEQ.nextval,?)";
              String generatedColumns[] = {"DIPOFFERTEID"};
              PreparedStatement preparedStatement = null;
              try {
                   //String gen[] = {"DIPOFFERTEID"};
                   PreparedStatement pstmt = conn.prepareStatement(hh, generatedColumns);
                   pstmt.setLong(1, 1);
                   pstmt.executeUpdate();
                   ResultSet rs = pstmt.getGeneratedKeys();
                   rs.next();
    //               The generated order id
                   long orderId = rs.getLong(1);

  • HOW CAN I  USE MULTIPLE INNERJOINS IN A SINGLE SELECT STATEMENT?

    HI,
    I AM SHABEER AHMED,
    I AM GETTING AN ERROR WHILE I ATTEMPT TO EXECUTE A SELECT STATEMENT WITH MULTIPLE INNER JOINS . BECOZ I WANT TO FETCH ITEM DATA, PARTNER DATA  BASED ON HEADER DATA .
    THEN OF COURSE I HAVE FETCH DATA FROM VBAK VBAP VBKD SO LZ SEND ME THE SOLUTION.
    BYE

    Hi,
    1.Just see this:
    SELECT * INTO CORRESPONDING FIELD OF TABLE itab
    FROM t1 INNER JOIN t2 ON t1f4 EQ t2f4
    INNER JOIN t3 ON t2f5 EQ t3f5 AND
    t2f6 EQ t3f6 AND
    t2f7 EQ t3f7.
    2.But better to use for all entries.It increases the performance.
    FOR ALL ENTRIES
    Tabular Conditions
    The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
    SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
    <cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
    The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
    You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
    Example for ALL ENTRIES
    DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
    TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT
    WITH UNIQUE KEY TABLE LINE,
    WA LIKE LINE OF TAB_SFLIGHT.
    SELECT CARRID CONNID
    INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI
    FROM SPFLI
    WHERE CITYFROM = 'NEW YORK'.
    SELECT CARRID CONNID FLDATE
    INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT
    FROM SFLIGHT
    FOR ALL ENTRIES IN TAB_SPFLI
    WHERE CARRID = TAB_SPFLI-CARRID AND
    CONNID = TAB_SPFLI-CONNID.
    LOOP AT TAB_SFLIGHT INTO WA.
    AT NEW CONNID.
    WRITE: / WA-CARRID, WA-CONNID.
    ENDAT.
    WRITE: / WA-FLDATE.
    ENDLOOP.
    INNER JOINS
    In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
    SELECT...
    FROM <tab> INNER JOIN <dbtab> AS <alias> ON <cond> <options>
    where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
    A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
    The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
    The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
    Example for INNER JOINS
    REPORT demo_select_inner_join.
    DATA: BEGIN OF wa,
    carrid TYPE spfli-carrid,
    connid TYPE spfli-connid,
    fldate TYPE sflight-fldate,
    bookid TYPE sbook-bookid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY carrid connid fldate bookid.
    SELECT pcarrid pconnid ffldate bbookid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( spfli AS p
    INNER JOIN sflight AS f ON pcarrid = fcarrid AND
    pconnid = fconnid )
    INNER JOIN sbook AS b ON bcarrid = fcarrid AND
    bconnid = fconnid AND
    bfldate = ffldate )
    WHERE p~cityfrom = 'FRANKFURT' AND
    p~cityto = 'NEW YORK' AND
    fseatsmax > fseatsocc.
    LOOP AT itab INTO wa.
    AT NEW fldate.
    WRITE: / wa-carrid, wa-connid, wa-fldate.
    ENDAT.
    WRITE / wa-bookid.
    ENDLOOP.
    Regards,
    Shiva Kumar(Reward if helpful).

  • Regarding Logical database and  select statement..

    Hi
    Experts.
    i would  like to  know the  diff b/w logical data base & select statement  while using report.
    wt is the use of logical databases in R/3. is there   any   advantage  used in the  reports.
    Thanks & Regards..
    Spandana.

    Dear Spandana,
      Go through the below description of LDB. I hope you wil get a fair amount of idea.
    SAP comes loaded with all the extras. Among the extras that are most helpful to IT managers are all the access routines needed to pull any business object that managers can think of out of SAP databases. However, SAP has not thought of everything where your particular applications are concerned. SAP organizes its standard database tables to service business units based on conventional business applications. Itu2019s likely your business requires something new, perhaps even something exotic. In that case, you will need to create a new database, using information from different places. Basically, you need a logical database. You need to create a virtual business data object repository consisting of a new kind of record or table that suits your purposes. In addition, the repository should be composed of information that is actually stored in a number of different locations, none of them necessarily logically associated with one another. Letu2019s take a closer look at creating logical databases.
    A case for a logical database
    Suppose my company manufactures widgets of the most obscure variety, and they are components of other widgets. I sell my widgets as raw material for the more sophisticated widgets built by others, but in some cases I actually partner with other manufacturers in creating yet another class of widget. Now, in my world, I consequently have customers who are also partners. I sell to them and I partner with them in manufacturing and distribution. Also, I need an application that uses both of these dual-use relationships.
    Essentially, I have a customer database and a partner database. Neither contains records that are structured to contain the identifying particulars of the other. Thus, I need a hybrid database that gives me tables detailing these hybrid relationships. What can I do? I can go the long way around and write a new database, pulling information from both and creating new objects with a customized program that I write by hand. However, this process is cumbersome and contains maintenance issues. On the other hand, I can use SAPu2019s logical database facility, create my logical database in a couple of minutes, and have no maintenance issues at all.
    Logical database structures
    There are three defining entities in an SAP logical database. You must be clear on all three in order to create and use one.
    u2022     Table structure: Your logical database includes data from specified tables in SAP. There is a hierarchy among these tables defined by their foreign keys (all known to SAP), and you are going to define a customized relationship between select tables. This structure is unique and must be defined and saved.
    u2022     Data selection: You may not want or need every item in the referenced tables that contributes to your customized database. There is a selection screen that permits you to pick and choose.
    u2022     Database access programming: Once youu2019ve defined your logical database, SAP will generate the access subroutines needed to pull the data in the way you want it pulled.
    Creating your own logical database
    ABAP/4 (Advanced Business Application Programming language, version 4) is the language created by SAP for implementation and customization of its R/3 system. ABAP/4 comes loaded with many predefined logical databases that can construct and table just about any conventional business objects you might need in any canned SAP application. However, you can also create your own logical databases to construct any custom objects you care to define, as your application requires in ABAP/4. Hereu2019s a step-by-step guide:
    1.     Call up transaction SLDB (or transaction SE36). The path you want is Tools | ABAP Workbench | Development | Programming Environment | Logical Databases. This screen is called Logical Database Builder.
    2.     Enter an appropriate name in the logical database name field. You have three options on this screen: Create, Display, and Change. Choose Create.
    3.     Youu2019ll be prompted for a short text description of your new logical database. Enter one. Youu2019ll then be prompted to specify a development class.
    4.     Now comes the fun part! You must specify a root node, or a parent table, as the basis of your logical database structure. You can now place subsequent tables under the root table as needed to assemble the data object you want. You can access this tree from this point forward, to add additional tables, by selecting that root node and following the path Edit | Node | Create. Once youu2019ve saved the structure you define in this step, the system will generate the programming necessary to access your logical database. The best part is you donu2019t have to write a single line of code.
    Watch out!
    The use of very large tables will degrade the performance of a logical database, so be aware of that trade-off. Remember that some tables in SAP are very complex, so they will be problematic in any user-defined logical database.
    Declaring a logical database
    Hereu2019s another surprising feature of logical databases: You do not assign them in your ABAP/4 Code. Instead, the system requires that you specify logical databases as attributes. So when you are creating a report, have your logical database identifier (the name you gave it) on hand when you are defining its attributes on the Program Attributes screen. The Attributes section of the screen (the lower half) will include a Logical database field, where you can declare your logical database.
    Logical databases for increasing efficiency
    Why else would you want to create a logical database? Consider that the logical databases already available to you begin with a root node and proceed downward from there. If the data object you wish to construct consists of items that are all below the root node, you can use an existing logical database program to extract the data, then trim away what you donu2019t want using SELECT statementsu2014or you can increase the speed of the logical database program considerably by redefining the logical database for your object and starting with a table down in the chain. Either way, youu2019ll eliminate a great deal of overhead.
    Regards
    Arindam

  • Optimizing a Select Statement

    Hi,
    I have recently been asked to generate a program that reports of payroll postings to FI.  This involves creating a giant select statement from the ppoix table to gather all the postings.  My select statement is as follows:
      SELECT pernr                       "EE Number
             seqno                       "Sequential number
             actsign                     "Indicator: Status of record
             runid                       "Number of posting run
             postnum                     "Number
             tslin                       "Line number of data transfer
             lgart                       "Wage Type
             betrg                       "Amount
            waers                       "Currency
            anzhl                       "Number
            meins                       "Base unit of measure
             spprc         "Special processing of posting items
            momag         "Transfer to FI/CO:EE grouping for acct determi
            komok         "Transfer to FI/CO: Symbolic account
            mcode                       "Matchcode search term
            koart                       "Account assignment type
            auart                       "Expenditure type
            nofin         "Indicator: Expenditure type is not funded
               INTO CORRESPONDING FIELDS OF TABLE i_ppoix
               FROM ppoix
               FOR ALL ENTRIES IN run_doc_xref
               WHERE runid  = run_doc_xref-runid
                 AND tslin  = run_doc_xref-linum
                 AND spprc  <> 'A'
                 AND lgart IN s_lgart
                 AND pernr in s_pernr.
    where s_pernr is a select option that holds personnel nummbers and s_lgart is a select option that holds wagetypes.  This statement works fine for a certain amount of personnel numbers and a certain amount of wagetypes, but once you exceed a certain limit the Database does not allow you to perform a select statement this large.  Is there a better way to perform such a large select such as this one) ie: FM, or some other method I am not aware of.  This select statement comes from the standard SAP delivered cost center admin report and this report dumps as well when too much data is passed to it.
    any ideas would be much appreciated.
    thanks.

    The problem here is with the select-options.
    For a select statement, you cannot have more that certain amount of data.
    The problem with your select becomes complex because of the FOR ALL ENTRIES in and the huge s_pernr and the 40 million records :(.
    I am guessing that the s_lgart will be small.
    How many entries do you have in internal table "run_doc_xref"?
    If there are not that many, then I would suggest this:
    TYPES:
      BEGIN OF ty_temp_ppoix,
       pernr   TYPE ppoix-pernr,
       lgart   TYPE ppoix-lgart,
       seqno   TYPE ppoix-seqno,
       actsign TYPE ppoix-actsign,
       runid   TYPE ppoix-runid,
       postnum TYPE ppoix-postnum,
       tslin   TYPE ppoix-tslin,
       betrg   TYPE ppoix-betrg,
       spprc   TYPE ppoix-spprc,
      END OF ty_temp_ppoix.
    DATA:
    i_temp_ppoix TYPE SORTED TABLE OF ty_temp_ppoix
       WITH NON-UNIQUE KEY pernr lgart
       INITIAL SIZE 0
       WITH HEADER LINE.
    DATA:
      v_pernr_lines TYPE sy-tabix,
      v_lgart_lines TYPE sy-tabix.
    IF NOT run_doc_xref[] IS INITIAL.
      DESCRIBE TABLE s_pernr LINES v_pernr_lines.
      DESCRIBE TABLE s_lgart LINES v_lgart_lines.
      IF v_pernr_lines GT 800 OR
         v_lgart_lines GT 800.
    * There is an index on runid and tslin. This should be ok
    * ( still bad because of the huge table :(  )
        SELECT pernr lgart seqno actsign runid postnum tslin betrg spprc
    * Selecting into sorted TEMP table here
          INTO TABLE i_temp_ppoix
          FROM ppoix
          FOR ALL ENTRIES IN run_doc_xref
          WHERE runid = run_doc_xref-runid
          AND   tslin = run_doc_xref-linum
          AND   spprc <> 'A'.
    * The sorted table should make the delete faster
        DELETE i_temp_ppoix WHERE NOT pernr IN s_pernr
                            AND   NOT lgart IN s_lgart.
    * Now populate the actual target
        LOOP AT i_temp_ppoix.
          MOVE: i_temp_ppoix-pernr TO i_ppoix-pernr.
    *  and the rest of the fields
          APPEND i_ppoix.
          DELETE i_temp_ppoix.
        ENDLOOP.
      ELSE.
        SELECT pernr seqno actsign runid postnum tslin lgart betrg spprc
    * Selecting into your ACTUAL target here
          INTO TABLE i_ppoix
          FROM ppoix
          FOR ALL ENTRIES IN run_doc_xref
          WHERE runid = run_doc_xref-runid
          AND   tslin = run_doc_xref-linum
          AND   spprc <> 'A'
          AND   pernr IN s_pernr
          AND   lgart IN s_lgart.
      ENDIF.
    ELSE.
    * Error message because of no entries in run_doc_xref?
    * Please answer this so a new solution can be implemented here
    * if it is NOT an error
    ENDIF.
    Hope this helps.
    Regards,
    -Ramesh

  • Delete adjacent duplicates how to use in the below select statement

    hi i have a problem
    i am suing the below select statement
    SELECT    a~extno
              a~guid_lclic       " for next select
              e~ctsim
              e~ctsex
    *revised spec 3rd
              f~guid_pobj
              f~amnt_flt
              f~amcur
              f~guid_mobj
              e~srvll     "pk
              e~ctsty     "PK
              e~lgreg  "PK
      INTO TABLE gt_sagmeld
      FROM /SAPSLL/LCLIC  as a
      INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
      inner join /sapsll/legcon as f on fguid_lclic = aguid_lclic   " for ccngn1 selection
      inner join /sapsll/corcts as g on gguid_pobj = fguid_pobj
                               where   a~extno in s_extno.
      sort gt_sagmeld by guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ.
      delete adjacent duplicates from gt_sagmeld comparing guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ .
    now i am confused how to use delete adjacent dupliacate and on which fields
    as first table /sal../lclic primary key is guid_lclic
    and it is joined to table
    legcon by guid_lclci ( not a primary key here)
    legcon primary key is guid_legcon
    and table 3 legsv by lgreg (pk here)
    table 3 has tow more primary key srvll and ctsty also
    NOW MY QUESTIO IS TAHT IS I USE ABOVE DELETE ADJACENT STATMENT IT FETCHES 20 LAKH RECORDS
    I WANT TO REDUCE IS LET ME KNOW ON WHAT fields i need to use delete adjacen duplicates
    or use comparing all fields?
    regards
    Arora

    hi sudha
    if u see my select statement is contains four Primary keys
    srvll
    lgreg
    ctsty
    guid_lclic
    but the next table connected to this table legcon is by guid_pobj and anothe table by guid_mobj
    and if i take this gt_sagmeld to another temp table and i find abt 10 lakh uniques guid_pobj
    similary 6 lakh guid_mobj so the next slect is hanpering because of this
    not COMING TO OUR POINT IF I SORT ONLY BY OUR PRIMARY KEYS NOT TAKING INTO ACCOUNT TEH GUID_POBJ AND GUID_MOBJ
    THE ENTRIES ARE VERY LESS BUT IF I TAKE INOT ACCCOUNT IN GT_SAGMELD THE ENTRIES ARE ABT 20 LAKH
    SO I AM NOT SURE WHETHER TO TAKNE GUID_POBJ AND GUID_MOBJ INOT ACCOUNT FOR DELECTING ADJACENT DUPLICATES?
    HENCE THE QUESTION OF ON WHICH FIRLD DELETE OR COMPARING ALL FIELDS I USE?

  • Variable in select statement - Is it possible!

    Hello All,
    I have a internal table with one column containing table names
    Field
    RSAABAP
    RSATABLE
    RSAFGA
    I need to read this internal table and write the content of each table on the screen.. like select * from...
    My question here is 
    Is it possible for me to use a statement like
    select * from tabname where this tabname is variable which could accomodate the table names like RSAABAP & so on..
    Thanks in advance!
    Karthik

    Yes it is possible:
    select *
    from ( v_tabname )
    into table itab.
    where..
    Refer the following example:
    <i><b>Example
    Dynamic specification of the inner joins. The column specification after SELECT is also dynamic.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    DATA: column_syntax TYPE string,
          dbtab_syntax TYPE string.
    column_syntax = `ccarrname pconnid f~fldate`.
    dbtab_syntax = `( ( scarr AS c `
      & ` INNER JOIN spfli AS p ON pcarrid  = ccarrid`
      & ` AND p~cityfrom = p_cityfr`
      & ` AND p~cityto   = p_cityto )`
      & ` INNER JOIN sflight AS f ON fcarrid = pcarrid `
      & ` AND fconnid = pconnid )`.
    SELECT (column_syntax)
           FROM (dbtab_syntax)
           INTO CORRESPONDING FIELDS OF TABLE itab.
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.</b></i>
    Regards,
    ravi

  • Passing of internal table values to the select statement as SETS

    Hi All,
    Is there any way that i can restrict the values of a internal table to be passed to a select statement set by set..
    say for eg: if a itab has 1000 entries i want the first 500 to be going out in a select statement as a comparision for all entries and then the next set of 500 to go out..
    Please let me know.. this is very urgent..

    <b>Appending Several Lines</b>
    You can also append internal tables to index tables using the following statement:
    APPEND LINES OF <itab1> TO <itab2>.
    This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.
    When you append an index table to another index table, you can specify the lines to be appended as follows:
    APPEND LINES OF <itab1> [FROM <n1>] [TO <n 2>] TO <itab2>.
    <n 1 > and <n 2 > specify the indexes of the first and last lines of ITAB1 that you want to append to ITAB2.
    This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX contains the index of the last line appended. When you append several lines to a sorted table, you  must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.
    Then u can use <b> FOR ALL ENTRIES</b> in select query.
    regards
    vinod

  • Select statement on cube

    Hi
    I am writing a routine (select statement) on the characterstics which has to get the data from other cube.
    My scenairo:
    Extracting the data from the flat file.
    In the cube i have a characteristics for which I need to pull the data from other cube.
    Routine:
    Select single xxxx into result from /bic/fsd_c03
    where bill_no = source_fields_rule-bill_no..
    When i click on the check, I am getting the following error" Unknown column name "XXXX" until runtime, you cannot specify a
    field list.
    Can we write select statements on cubes? or is there any issue in my routine?
    Thanks
    Annie

    Hi Annie,
    I would suggest not because of the following reasons:
    1) The way data is stored in the Info cube is multi-dimensional, which means to say that all the characteristic are grouped into dimensions and they result in unique dimension ID's which connect to your fact table (/BI0/F*)
    This would mean, your characteristics and key figures would not be available in the same table for doing the select.
    2) If you happen to compress the data in the infocube, the data in the fact table would be  moved to the E fact table (/BI0/E) from the f fact table (/BI0/F).
    This would need change of code.
    I would rather suggest to go about this way.
    --> Check if the cube which you are trying to do a lookup is fed from a DSO.
    --> If so, use the Active table(/BI0/A*00) of the DSO for the lookup.
    Hope this helps!
    Edited by: Suchindra B R on Feb 10, 2010 7:45 AM

  • 'FOR ALL ENTRIES' in SELECT statements

    Hi,
    I got a doubt in working of the 'FOR ALL ENTRIES' option in the SELECT statement. Here is my scenarion.
    Table A - Document Header Level (Key: Doc Number)
    Internal Table B - Document Item level (Keys: Doc num and Doc Item).
    So, for each record in Table A, table B will have multiple records.
    In this situation, how the below SELECT will work.
    SELECT <field names> INTO <some internal table>
                         FROM A
                         FOR ALL ENTRIES in B
                         WHERE doc_num = B-doc_num.
    Will the above SELECT result in duplicate records or not?
    (I tested it and found that it doesn't! I was lil surprised and wanted to confirm that)
    Thanks & Regards,
    Sree

    Hi,
    For all entries option basically sorts out the entries in the internal tbale based on the where condition and thus it only picks the unique entries based on the list.
    so indeed your table A is a header one so it will give you only single value. if you go by the reverse way where in look for B for all entries in A it will give you multiple values as table B has multiple values for each value in A.
    Regards,
    Jagath

  • DISTINCT in SELECT statements for  Entities / Views - Oracle JDeveloper 11G

    Hi Steve,
    i have a question about using DISTINCT in SELECT statements for
    Entities / Views. On Oracle JDeveloper 11G ADF / BC4J
    --- This is unique---
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    from "grp_courses" GC
    --- This is NOT unique, but ROWID seems to be mandatory as PrimaryKey---
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    rowid
    from "grp_courses" GC
    How to use this query;
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    from "grp_courses" GC
    and yet still be able to use it in View / Entity without a Primary Key or some equivalent solution.
    Thanks & Regards,

    Hi, OK - I got it to work...
    Some notes:
    1) The View wizard cannot be initiated from the Entity Object.
    2) During the View wizard process - do not associate with Entity
    3) Selected columns must be mapped as expressions
    4) Using non-distinct columns will override the distinct function

  • For update in select statement

    i have a table which store data in a clob. sometimes user forget to add and extra carriage return after last line. so i am doing the following to modify the clob
    SELECT file_content INTO lv_lob FROM files WHERE id = p__id FOR UPDATE;
    dbms_lob.writeappend(lv_lob,2,C_NEW_LINE);
    C_NEW_LINE CONSTANT VARCHAR2(2) := Chr(13)||Chr(10);
    'for update' should only lock that specific row since id is a pk key in the table.
    i have two front end screen where people upload file. a unique id is generated for each file and the data with id inserted in the table. user can upload file from the two different screen at same time.
    the problem is that i am getting a 'resource busy and acquire with NOWAIT specified' error. i don't know why if every file i upload belongs to different row.
    anybody knows why i would get this error and how can i solve it?

    How are you generating the unique ID? Are you using a sequence? Or are you using something that forces serialization?
    Where in the program flow are you adding the extra carriage return?
    Is it this SELECT statement that is throwing the error? Or is it being thrown somewhere else?
    Justin

  • How to utilize index in selection statement

    hi
    how to utilize index in selection statement and how is it reduces performance whether another alternative is there to reduce performance .
    thanks

    Hi Suresh,
    For each SQL statement, the database optimizer determines the strategy for accessing data records. Access can be with database indexes (index access), or without database indexes (full table scan).The cost-based database optimizer determines the access strategy on the basis of:
    *Conditions in the WHERE clause of the SQL statement
    *Database indexes of the table(s) affected
    *Selectivity of the table fields contained in the database indexes
    *Size of the table(s) affected
    *The table and index statistics supply information about the selectivity of table fields, the selectivity of combinations of table fields, and table size.     Before a database access is performed, the database optimizer cannot calculate the exact cost of a database access. It uses the information described above to estimate the cost of the database access.The optimization calculation is the amount by which the data blocks to be read (logical read accesses) can be reduced. Data blocks show the level of detail in which data is written to the hard disk or read from the hard disk.
    <b>Inroduction to Database Indexes</b>
    When you create a database table in the ABAP Dictionary, you must specify the combination of fields that enable an entry within the table to be clearly identified. Position these fields at the top of the table field list, and define them as key fields.
    After activating the table, an index is created (for Oracle, Informix, DB2) that consists of all key fields. This index is called a primary index. The primary index is unique by definition. As well as the primary index, you can define one or more secondary indexes for a table in the ABAP Dictionary, and create them on the database. Secondary indexes can be unique or non-unique. Index records and table records are organized in data blocks.
    If you dispatch an SQL statement from an ABAP program to the database, the program searches for the data records requested either in the database table itself (full table scan) or by using an index (index unique scan or index range scan). If all fields requested are found in the index using an index scan, the table records do not need to be accessed.
    A data block shows the level of detail in which data is written to the hard disk or read from the hard disk. Data blocks may contain multiple data records, but a single data record may be spread across several data blocks.
    Data blocks can be index blocks or table blocks. The database organizes the index blocks in the form of a multi-level B* tree. There is a single index block at root level, which contains pointers to the index blocks at branch level. The branch blocks contain either some of the index fields and pointers to index blocks at leaf level, or all index fields and a pointer to the table records organized in table blocks. The index blocks at leaf level contain all index fields and pointers to the table records from the table blocks.
    The pointer that identifies one or more table records has a specific name. It is called, for example, ROWID for Oracle databases. The ROWID consists of the number of the database file, the number of the table block, and the row number within the table block.
    The index records are stored in the index tree and sorted according to index field. This enables accelerated access using the index. The table records in the table blocks are not sorted.
    An index should not consist of too many fields. Having a few very selective fields increases the chance of reusability, and reduces the chance of the database optimizer selecting an unsuitable access path.
    <b>Index Unique Scan</b>
    If, for all fields in a unique index (primary index or unique secondary index), WHERE conditions are specified with '=' in the WHERE clause, the database optimizer selects the access strategy index unique scan.
    For the index unique scan access strategy, the database usually needs to read a maximum of four data blocks (three index blocks and one table block) to access the table record.
    <b><i>select * from VVBAK here vbeln = '00123' ......end select.</i></b>
    In the SELECT statement shown above, the table VVBAK is accessed. The fields MANDT and VBELN form the primary key, and are specified with '=' in the WHERE clause. The database optimizer therefore selects the index unique scan access strategy, and only needs to read four data blocks to find the table record requested.
    <b>Index Range Scan</b>
    <b><i>select * from VVBAP here vbeln = '00123' ......end select.</i></b>
    In the example above, not all fields in the primary index of the table VVBAP (key fields MANDT, VBELN, POSNR) are specified with '=' in the WHERE clause. The database optimizer checks a range of index records and deduces the table records from these index records. This access strategy is called an index range scan.
    To execute the SQL statement, the DBMS first reads a root block (1) and a branch block (2). The branch block contains pointers to two leaf blocks (3 and 4). In order to find the index records that fulfill the criteria in the WHERE clause of the SQL statement, the DBMS searches through these leaf blocks sequentially. The index records found point to the table records within the table blocks (5 and 6).
    If index records from different index blocks point to the same table block, this table block must be read more than once. In the example above, an index record from index block 3 and an index record from index block 4 point to table records in table block 5. This table block must therefore be read twice. In total, seven data blocks (four index blocks and three table blocks) are read.
    The index search string is determined by the concatenation of the WHERE conditions for the fields contained in the index. To ensure that as few index blocks as possible are checked, the index search string should be specified starting from the left, without placeholders ('_' or %). Because the index is stored and sorted according to the index fields, a connected range of index records can be checked, and fewer index blocks need to be read.
    All index blocks and table blocks read during an index range scan are stored in the data buffer at the top of a LRU (least recently used) list. This can lead to many other data blocks being forced out of the data buffer. Consequently, more physical read accesses become necessary when other SQL statements are executed
    <b>DB Indexex :Concatenation</b>
         In the concatenation access strategy, one index is reused. Therefore, various index search strings also exist. An index unique scan or an index range scan can be performed for the various index search strings. Duplicate entries in the results set are filtered out when the search results are concatenated.
    <i><b>Select * from vvbap where vbeln in ('00123', '00133', '00134').
    endselect.</b></i>
    In the SQL statement above, a WHERE condition with an IN operation is specified over field VBELN. The fields MANDT and VBELN are shown on the left of the primary index. Various index search strings are created, and an index range scan is performed over the primary index for each index search string. Finally, the result is concatenated.
    <b>Full Table Scan</b>
    <b><i>select * from vvbap where matnr = '00015'.
    endselect</i></b>
    If the database optimizer selects the full table scan access strategy, the table is read sequentially. Index blocks do not need to be read.
    For a full table scan, the read table blocks are added to the end of an LRU list. Therefore, no data blocks are forced out of the data buffer. As a result, in order to process a full table scan, comparatively little memory space is required within the data buffer.
    The full table scan access strategy is very effective if a large part of a table (for example, 5% of all table records) needs to be read. In the example above, a full table scan is more efficient than access using the primary index.
    <i><b>In Brief</b></i>
    <i>Index unique scan:</i> The index selected is unique (primary index or unique secondary index) and fully specified. One or no table record is returned. This type of access is very effective, because a maximum of four data blocks needs to be read.
    <i>Index range scan:</i> The index selected is unique or non-unique. For a non-unique index, this means that not all index fields are specified in the WHERE clause. A range of the index is read and checked. An index range scan may not be as effective as a full table scan. The table records returned can range from none to all.
    <i>Full table scan:</i> The whole table is read sequentially. Each table block is read once. Since no index is used, no index blocks are read. The table records returned can range from none to all.
    <i>Concatenation:</i> An index is used more than once. Various areas of the index are read and checked. To ensure that the application receives each table record only once, the search results are concatenated to eliminate duplicate entries. The table records returned can range from none to all.
    Regards,
    Balaji Reddy G
    ***Rewards if answers are helpful

Maybe you are looking for

  • Pro*C program fails in Oracle 11g enviroment.

    Hi, Right now we have oracle 10g environment in production and Pro*C program compilation and execution works fine. We are upgrading Oracle 10g to Oracle 11g. When I test the Pro*C program compilation and execution in Oracle 11g environment, the compi

  • Scrambled order of images via Apple TV from shared folder

    When I select a folder of images on my computer which are sorted in ascending number in the folder, the set of images I then view on my TV is partially scrambled!  Why don't they appear in the numeric order which I created in the folder?  I have adde

  • Drafts Not Available for Publish

    Using Contribute CS3 and CPS. Draft is sent for review. It is reviewed by the admin. Admin goes to "publish" and Contribute says that the Draft is not available to publish. The person who created the draft - his PC was on. Any ideas on why this happe

  • Material master data BAPI and LSMW log

    I have three questions want to ask : 1. I will use all the view  to create material master. I want to know if there is one BAPI to create it.? 2. If I use LSMW to create it, in LSMW i use the BAPI method to create it. But I should to know the detail

  • Reinstalling Facebook Apps

    after deleting twice facebook apps on my ipad mini, i cannot re install for the third time..but before deleting it, there is another problem, i canoot logged in my fb account so i deleted it and reinstall it, i did it twice..and now i cannot reinstal