Query in select statment

Hi ,
    what is the difference between,select single and
select upto one row .
In a select statment .
Thanks ,
shankar.

According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not
using all the primary key fields.
select single is a construct designed to read database records with primary key. In the absence of the primary key,
it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key
supplied and will try to find most suitable index.
The best way to find out is through sql trace or runtime analysis.
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s)
you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the
second or the third record has the value you are looking for.
The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional
level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause
If this results in multiple records then only the first one will be returned and therefore may not be unique.
Mainly: to read data from
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that
are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns
the first record of the result set.
Mainly: to check if entries exist.
You can refer to the below link..
http://www.sap-img.com/abap/difference-between-select-single-and-select-upto-one-rows.htm

Similar Messages

  • Select statment Query

    Hi,
    I am devloping Query  with the table DBERCHZ1
    it  having  two fields
        V_ ABRMENGE        value  456
       N_ ABRMENGE        value   0.67899
    Here i want  to print as  456.67899  with  one  select  statment.
    is  any way  to sum  in select  statment.
    Thanks

    Hi,
    I have just given a code snippet similar to your requirement.
    DATA:   average TYPE p DECIMALS 2,
            sum     TYPE p DECIMALS 2.
    SELECT AVG( luggweight ) SUM( luggweight )
      INTO (average, sum)
      FROM sbook.
    WRITE: / 'Average:', average,
           / 'Sum    :', sum.
    Just replace with your variables and let me know if it works.
    Thanks,
    Harini

  • How does "SELECT" statment  work?

    Hi,
    Correct me if I'm wrong.
    Data selected by SELECT statement  (without ORDER BY) is unordered and sequence of selected lines may differ every time you execute the same SELECT.
    My problem is that data on a production system has been always selected ordered ( without ORDER BY)  and suddenly it changes and the rows of a result set are unordered.
    It's also strange for me that it works differently on a test system and data is selected ordered ( the code is the same on both systems ).
    Two questions:
    1. How is it possible that data was always selected ordered? (the only answer which comes to my head is "LUCK" )
    2. What has happened that data is now selected unordered? (and works as SELECT statment should work by definition)
    Thanks for any ideas,
    Mario

    Hello,
    I see there is an equality 3-3 in the match here, between
    1) those who are for "it's ordered" (Rodrigo Ariel G..., Danish2285, pavankumar.g)
    2) and those "it's not ordered" (Diwakar Aggarwal, Keshav.T, Matt).
    So I'd like to play too :-D and my answer is "it's not ordered" (with Diwakar Aggarwal, Keshav.T, Matt).
    now 3-4
    My advice is: always trust the SAP documentation when it's said explicitly (I'm aware that the arguments or context are sometimes missing, so a confirmation is then needed).
    You'll find it also in the wikipedia for SQL article (http://en.wikipedia.org/wiki/SQL#Queries): "The ORDER BY clause identifies which columns are used to sort the resulting data, and in which direction they should be sorted (options are ascending or descending). Without an ORDER BY clause, the order of rows returned by an SQL query is undefined."
    Oracle SQL Reference, in the Query Optimizer section (http://download.oracle.com/docs/cd/B14117_01/server.101/b10752/optimops.htm#35891) : "If data must be sorted by order, then use the ORDER BY clause, and do not rely on an index. If an index can be used to satisfy an ORDER BY clause, then the optimizer uses this option and avoids a sort."
    In fact, this is logic when we know how RDBMS are built, all this is about the selection of the access path to get the data (that we see with the explain plan, the path depends especially on what the database contains, that is different between test and production), the faster way to do things (an ordering is not always required, so why the RDBMS would spend time to organize it)
    Don't we have this question in the Forum's FAQ by the way?
    Sandra

  • To create query with selecting condition have AND options

    Hi All ,
    I want to create a query in SQ01 . I want to get  data from a table whose one specific field have data starting with  Z  AND  Z : * ( not OR )*  .  Is it possible to do any thing in the selection screen or i have to do any other change ?
    Please help me in this.
    Thanks & Regards ,
    Sabu.

    Hi
    Your select statment u can have
    field in ( 'Z%' , 'Z:%')
    you will get all fields starting with z and Z;
    regards

  • Query on Select Statement

    Dear All,
            I have a small query on the Select Statement. If there are 2 identical rows and if i am retrieving them using the Select Statement, then will the select statement retrieves both the rows which are identical or only the first possible occurence? Pls help me out in this.
    Thanks,
    Sirisha.

    Hi,
         That depends on the statement u use. If u use, 'SELECT' statment, u can retrieve all the records which are identical with one or few fields. For that, u need to put the output INTO A TABLE.
    Ex. 1
    data : int_ekko type table of ekko with header line,
             fs_ekko type ekko.
    select * from ekko into table int_ekko where ebeln = '6361003191'.
    Here, int_ekko is an internal table contains all records whose EBELN = 63610003191.
    2)  If u use 'SELECT  SINGLE', then it will retrieve only the first record out of all the records who satisfy the condition EBELN = 6361003191.
    Ex 2:
    select single * from ekko into fs where ebeln = '63610003191'.
    'fs' is not a table, just of type structure. so contains only one record.
    Hope it help u..
    Kindly reward points if hepful
    Regards,
    Shanthi.
    Edited by: Shanthi on Mar 4, 2008 8:17 AM

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • In oracle rac, If user query a select query and in processing data is fetched but in the duration of fetching the particular node is evicted then how failover to another node internally?

    In oracle rac, If user query a select query and in processing data is fetched but in the duration of fetching the particular node is evicted then how failover to another node internally?

    The query is re-issued as a flashback query and the client process can continue to fetch from the cursor. This is described in the Net Services Administrators Guide, the section on Transparent Application Failover.

  • How to get all rows that are returned in inner sub query of select statemen

    If a sub query in select statement returns more than one row than how to get all those returned rows in the final
    output of the query .It will be all right if all column's value repeat and that multiple output of inner query comes
    in another column .
    How to get that ?

    As Frank said, you likely want a join, and likely an outer join to replicate the select in the projection. Something like:
    SELECT id,stat, section, USER_ID concerned_person
    FROM table_all,
      left join table2
        on room_id = sectoion and
           sur_role = 'r001'
    WHERE section IN (SELECT code
                      FROM t_area
                      WHERE dept= 'p002')An alternative, depending on where and how you are using the statement would be something like:
    SQL> WITH t AS (
      2    select 1 id from dual union all
      3    select 2 id from dual),
      4  t1 as (
      5    select 1 id, 'One' descr from dual union all
      6    select 1, 'Un' from dual union all
      7    select 1, 'Une' from dual)
      8  SELECT t.id, CURSOR(SELECT t1.id, t1.descr from t1
      9                      WHERE t1.id = t.id)
    10  FROM t;
                      ID CURSOR(SELECTT1.ID,T
                       1 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
                      ID DESCR
                       1 One
                       1 Un
                       1 Une
                       2 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    no rows selectedJohn

  • Performace problem in a select statment how to imporve the performance

    fist select statment
    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
    * revised spec 3rd
      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 guid_pobj.
    lgreg ctsty srvll
      delete adjacent duplicates from gt_sagmeld comparing guid_lclic guid_pobj.
    it selects about 20 lakh records
    belos select statment whichs is taking time as it is based on the entreis of gt_sagmeld
    select /sapsll/corpar~guid_mobj
                /sapsll/corpar~PAFCT
                but000~bpext
                but000~partner
                /sapsll/corpar~parno
                into table gt_but001
        from    /sapsll/corpar
        INNER join but000  on  but000partner = /sapsll/corparparno
        for all entries in gt_sagmeld
        where  /sapsll/corpar~guid_mobj = gt_sagmeld-guid_mobj
        and    /sapsll/corpar~PAFCT = 'SH'.
       SELECT /sapsll/cuit~guid_cuit         " PK
              /sapsll/cuit~QUANT_FLT         " to be displayed
              /sapsll/cuit~QUAUM             " to be displayed
              /sapsll/cuit~RPTDT             " to be displayed
             /sapsll/cuhd~guid_cuhd         " next select
              /sapsll/cuit~guid_pr           " next select
      INTO table gt_sapsllcuit
      FROM  /sapsll/cuit
    inner join /sapsll/cuhd on /sapsll/cuitguid_cuhd = /sapsll/cuhdguid_cuhd
      FOR all entries in gt_sagmeld
      WHERE /sapsll/cuit~guid_cuit = gt_sagmeld-guid_pobj.
      Delete adjacent duplicates from gt_sapsllcuit[].
           if not gt_sapsllcuit[] is initial.

    hi navenet
    that didnt worked
    we need to try ur range options
    but not sure what you told in the last mail as not clear with range can u pls eloboragte more i am pasting the full code here
    SELECT     a~extno
               a~guid_lclic       " for next select but000
               e~ctsim
               e~ctsex
               e~srvll
               e~ctsty
               e~lgreg
      INTO TABLE gt_sagmeld
      FROM /SAPSLL/LCLIC  as a
      INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
                               where   a~extno in s_extno.
    sort gt_sagmeld by guid_lclic.
    delete adjacent duplicates from gt_sagmeld comparing all fields.
      IF not gt_sagmeld[] is initial.
      SELECT  /sapsll/legcon~guid_lclic
              /sapsll/legcon~guid_pobj
              /sapsll/legcon~amnt_flt
              /sapsll/legcon~amcur
               but000~bpext
               *revised spec
               /sapsll/corpar~PAFCT
              /sapsll/legcon~guid_mobj
             /sapsll/cuit~guid_cuit
      INTO TABLE gt_but000
      FROM /SAPSLL/LEGCON
      for all entries in gt_sagmeld
      where /SAPSLL/legcon~guid_lclic = gt_sagmeld-guid_lclic.
            IF NOT GT_BUT000[] IS INITIAL.
           sort gt_but000 by guid_mobj.
           delete adjacent duplicates from gt_but000 comparing guid_mobj.
         select /sapsll/corpar~guid_mobj
                /sapsll/corpar~PAFCT
                /sapsll/corpar~parno
                into table gt_but001
        from    /sapsll/corpar
        for all entries in gt_but000
        where  /sapsll/corpar~guid_mobj = gt_but000-guid_mobj.
       and    /sapsll/corpar~PAFCT = 'SH'.
    DELETE gt_but001 where PAFCT <> 'SH'.
    *sort gt_corpar by parno.
    *delete adjacent duplicates from gt_corpar comparing parno.
    *select gd000~partner
          gd000~bpext
         from gd000 into table gt_but001
    for all entries in gt_corpar
    where  gd000~partner = gt_corpar-parno.
    my ultimat aim is to select bpext from gd000
    can u please explain how to use ranges here and what is the singnificance and how ill i read the data from the final  table if we use ranges
    regards
    Nishant

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • The parameter name [...] in the query's selection criteria does not match..

    Hi all,
    I'm trying to pratice EJB 3 (which I learnt at school), with JSF and JPA, but i'm really stuck with that error :
    Exception [TOPLINK-6094] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.QueryException
    Exception Description: The parameter name [departmentID] in the query's selection criteria does not match any parameter name defined in the query.
    Query: ReadAllQuery(oracle.datamodel.Employees)
    I will try to explain clearly what i'm trying to do :
    In fact, i'm following that tutorial :
    http://www.oracle.com/technology/obe/obe1013jdev/10131/ejb_and_jpa/master-detail_pagewith_ejb.htm
    But, as i didn't have any oracle database, but had a mysql one on my machine, i decided to use that DB instead of the the oracle DB... So i created a set of example data (to replace the oracle example set) ...so i created the tables EMPLOYEE, and DEPARTMENT... with the correct relations (FK) and PK)
    All was ok, i choose my "mysql-connector" (jdbc) instead of the oracle jdbc connector... so i could follow the tutorial.
    My problem appears at the step 12 (of "Creating a Master-Detail JavaServer Faces Page"), when i run the file deptEmployees.jspx.
    The information of the first departement displays correctly :
    departmentID 1
    departmentName ... etc
    but it can't display the employees belonging to that department !
    the error is :
    JBO-29000: Exception Description: The parameter name [departmentID] in the query's selection criteria does not match any parameter name defined in the query. Query: ReadAllQuery(oracle.datamodel.Employees)
    I think i understand what is the problem... I think that the query in charge of gathering the data of a specific departement need a parameter, but couldn't find it. But i don't know why :-/ I have tried many things and read the topics talking about that error... but it didn't solved the problem. I don't know anymore where to investigate.
    I have created a Zip file of my work (it's an EJB/JSF Application.. with jdev 10.1.3.3.0)
    (available here : http://dl.free.fr/mQ5esdQuS/EJB_appli.zip)
    I would be glad if someone could take few minutes to help me.
    Thank you in advance,
    Thomas B (student)

    Hello,
    This is a common mistake. Java string comparisons in TopLink are case sensitive by default, and since column names are uppercase when defaulted, TopLink cannot find the "departmentID" column name. In this case, Departments ID column defaults to "DEPARTMENTID" as required by the JPA specification.
    Either change Departments id annotation to     @Id
        @Column(name="departmentID", nullable = false)
        private Integer departmentID;or change Employees' ManytoOne annotation to:
        @ManyToOne
        @JoinColumn(name = "departmentID", referencedColumnName = "DEPARTMENTID")
        private Departments departments;Best Regards,
    Chris

  • Impact of selecting "Removing Query from Selection List" in 2 channels.

    HI All ,
    I have customized a query in one channel (My Agreements and Contract Documents query in Master Agreements List channel) and have removed the standard query from the channel by checking the  "Remove Query from Selection List" and introduced my custom query in that query group .
    But  it resulted in break in chain for  "Master Agreements" link in "Contracts To Do List" channel as the link was pointing to standard  "My Agreements and Contract Documents" query and is displaying "The query can not be executed. Contact your system administrator" when ever I click on that.
    Any pointers on how to overcome above scenario wud be gr8!
    Regards,
    Uday

    Hi Uday,
    In order for To Do List channel to work, the query definition should be in the Master Agreement List query group. Do you still want the standard query in the To Do List? If so, you would have to leave it on the Query Group as To Do list is pointing to it. May be change the display name of the query so you can differentiate between the 2 queries. The other option is change the To Do channel to point to the custom query.
    Regards,
    Vikram

  • Dynamic Query for 'Select IN' -- URGENT!!!

    I've got the following Select statement -
    SELECT Employee_Name, SSN FROM Company
    WHERE EMPLOYEE_NAME IN (c_Employee_Name) ;
    Here c_Employee_Name is a Returned RefCursor from another function. It gives error as Type mismatch.
    Is there anyway I can run one SELECT statement for all the Employee_Name returned by the function?
    Any sample code will be great.
    Thanks a lot,
    Suman

    If you have a packaged function that returns a ref cursor,
    something like this:
    CREATE OR REPLACE PACKAGE package_name
    AS
      TYPE c_employee_name IS  REF cursor;
      FUNCTION function_name
        (p_tables      IN  VARCHAR2,
         p_columns     IN  VARCHAR2 DEFAULT '*',
         p_where       IN  VARCHAR2 DEFAULT ' 1 = 1 ',
         p_others      IN  VARCHAR2 DEFAULT NULL)
        RETURN package_name.c_employee_name;
    END package_name;
    CREATE OR REPLACE PACKAGE BODY package_name
    AS
      FUNCTION function_name
        (p_tables      IN  VARCHAR2,
         p_columns     IN  VARCHAR2 DEFAULT '*',
         p_where       IN  VARCHAR2 DEFAULT ' 1 = 1 ',
         p_others      IN  VARCHAR2 DEFAULT NULL)
        RETURN package_name.c_employee_name
      IS
        v_sql              VARCHAR2 (4000) := NULL;
        v_results          package_name.c_employee_name;
      BEGIN
        v_sql :=
           ' SELECT ' || p_columns
        || ' FROM '   || p_tables
        || ' WHERE '  || p_where || ' '
        || p_others;
        OPEN v_results FOR v_sql;   
        RETURN v_results;
      END function_name;
    END package_name;
    Then, you can use a procedure, something like the
    one below, to call the function and loop through
    the ref cursor to concatenate a string of employee
    names to be used in the select statement.  You can
    then open another ref cursor for that select statment
    and process the results however you like.  I used
    dbms_output in the following example:
    CREATE OR REPLACE PROCEDURE procedure_name
    AS
      c_employee_names  package_name.c_employee_name;
      v_employee_name   company.employee_name%TYPE;
      v_employee_names  VARCHAR2 (4000) := NULL;
      v_delimiter       VARCHAR2 (1) := NULL;
      v_sql             VARCHAR2 (4000) := NULL;
      TYPE cursor_type IS REF CURSOR;
      cursor_name cursor_type;
      v_ssn             company.ssn%TYPE;
    BEGIN
      c_employee_names := package_name.function_name
                            ('company', 'employee_name');
      LOOP
        EXIT WHEN c_employee_names%NOTFOUND;
        FETCH c_employee_names INTO v_employee_name;
        v_employee_names := v_employee_names
        || v_delimiter
        || v_employee_name;
        v_delimiter := ',';
      END LOOP;
      v_employee_names := REPLACE (v_employee_names, ',', ''',''');
      v_sql := ' SELECT employee_name, ssn'
            || ' FROM   company'
            || ' WHERE  employee_name IN ('''
            || v_employee_names
            || ''')';
      OPEN cursor_name FOR v_sql;
      LOOP
        EXIT WHEN cursor_name%NOTFOUND;
        FETCH cursor_name INTO v_employee_name, v_ssn;
        DBMS_OUTPUT.PUT_LINE (v_employee_name || ' ' || v_ssn);
      END LOOP;
      CLOSE cursor_name;
    END procedure_name;
    To execute the procedure that calls the function:
    SET SERVEROUTPUT ON
    EXEC procedure_name

  • Select statment - fill internal table

    Hi,
    I have following situation:
    TYPES: BEGIN OF q_data,
             i_lqua LIKE lqua,
             v_xxx(20) type c,
           END OF q_data.
    DATA: a_data TYPE STANDARD TABLE OF q_data.
    Now I would write a select statment and fill the table a_data.
    select lqua~matnr lqua~werks... from lqua inner join mch1 into (i_lqua-matnr, i_lqua-werks.....)...
    Is it possible to write a statement without writing the whole structure (all the names of columns) of lqua in the SQL-statement (lquamatnr lquawerks lqua~........)?
    Thanks
    Michael

    1. you can write that but i think you have to write that in SELECT ...ENDSELECT.
    select lquamatnr lquawerks... from lqua inner join mch1 into (i_lqua-matnr, i_lqua-werks.....
    append i_lqua.
    endselect.
    2. OR you can use INTO CORRESPONDING FIELDS OF TABLE
       select lquamatnr lquawerks... from lqua inner join mch1 into corresponding fields of table i_lqua.

  • Limiting Query View selections for Web reports

    In web reports, users currently have Query View Selection but they want to be  able to just see views that they have created and not all others. 
    How can this be done?
    Does creating views in web and in BEX pull different auth objects or is it same? - Which objects are check in WEB views? Bex views use s_rs_comp with the QVW componenet.. but the trace does not show any log like this.

    Hi,
    User specific protection of queries are controlled by authorization object S_RS_COMP1.
    Authorization RSZOWNER = "$USER" allows the user access to activities in all the components he is an owner of.
    Check out this link, the analyst 3 scenario is what you are looking for:
    http://help.sap.com/saphelp_nw04/helpdata/EN/41/05453caff4f703e10000000a114084/content.htm
    Regards,
    Zaheer

Maybe you are looking for

  • IPad WiFi Issues are an Apple Problem

    It seems clear many are having WiFi issues. While there are some suggestions involving changes to routers, these in general are at best temporary work arounds. 1. Not everyone has any ability to change things about the router they connect with. 2. Th

  • Help!!! No MMS function

    Hey I'm new to forums and looking for help I just bought a new BB 8330 phone off ebay. I have no MMS function. How do I solve this?

  • "Site System Status Summarizer still cannot access storage object" after DB Move

    After our SCCM server was up and running, the DBAs moved the SQL Site Database to a new drive which is a supported SQL Operation according to this Support document: https://support.microsoft.com/en-us/kb/2709082 Using the methods described by the abo

  • Why can't I get gmail out of firefox?

    Same as so many other people have put down. I can't get gmail!! Then I see someone solved it, I click on solved and get nothing

  • What an item's cost price will be if I build and sell it today?

    Hi experts I want to know what an itemu2019s cost price will be if I build and sell it today, with current raw material prices based on the FIFO layers with multiple BOMu2019s. your response will be highly appreciated thanks Travelyn Swartz