Query in SELECT statement!!!!

Hi all,
          I have a SELECT statement as follows:
  SELECT aguid_hi bpartner_no
  FROM crmd_link AS a
  INNER JOIN crmd_partner AS b ON bguid EQ aguid_set
  INTO TABLE p_partners
  FOR ALL ENTRIES IN i_sub_contracts
  WHERE a~guid_hi     EQ i_sub_contracts-guid
    AND a~objtype_hi  EQ '05'
    AND b~partner_fct EQ p_partner_fct.
Please tell me if I can create a view for the above.
Once I create a view for the above will it really boost the performance.
Kindly reply immediately as this is bit urgent.
Regards,
Vijay

hi,
As said above view is nothing but an inner join between tables which you are already doing it in your program ... So i don't think there will be any improvement in the performance of the program ...
Regards,
Santosh

Similar Messages

  • 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

  • Query for select statement

    Dear all
    is there any option in select statement to automatically generate serial number respect of data.
    for eg.
    1 101100110  shetal trade
    2 1110001178 CHEMICAL SOAP WORKS
    3..
    4..
    i don't  want to use loop (sy-tabix) ..
    thanks,
    Abhi

    Hi ,
    i don't want to use loop (sy-tabix) ..
    any particular reason for this ?
    as u cannot automatically generate serial number, u have to go for loop....endloop.
    Thanks
    Karthik

  • Urgent :  Query on select statement!!

    Hi All,
    i am trying to get the customer number from VBPA table into my work area based on vbeln and parvw values. but it is giving me an sysubrc value is 4.
    here is my code :
      select single kunnr into wa_i_vbpa
                          from vbpa
                          where vbeln = p_i_vbeln
                          and   parvw = 'SP'.
    Kindly check and let me know whether this is correct or not? if not, please correct it and send it to me back.
    Thanks in advance.

    Hi,
    Please try this instead.
    select single kunnr into wa_i_vbpa
    from vbpa
    where vbeln = p_i_vbeln
    and parvw = 'AG'.
    Regards,
    Ferry Lianto

  • 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

  • Combine two select statements in one SQL statements

    I have the following two queries that I need to combine into one query, where it updates a single row at the same time.
    SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = "4837"
    SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = "4837"
    I want to insert the values of each select statement into two columns of the same row, as well as insert the account number from the select statement.
    After the query has been executed, the database row will look like this:
    ACCOUNT COUNT SUM
    4837 354 1039202
    I am looking for suggestions on how to:
    - either combine the two into one query
    - simply update each column with the value from each query by updating the row with the account value
    I am a SQL newbie - so I appreciate any assistance.
    Thanks,
    Tony

    Hi, Tony,
    When you're talking about changing the data in tables, "INSERT" means to add a new row, and you'll cause a lot of confusion if you use it to mean something else. So don't say
    "I want to insert the values of each select statement into two columns..."; use some other word, like:
    "I want to put the values of each select statement into two columns ..."
    If you happened to know that those two numbers were 354 and 1039202, you might say:
    UPDATE  table_x
    SET     a_count = 354
    ,       a_sum = 1039202
    WHERE   account = 4837;But you don't know the numbers; you want to have the query figure out what they are.
    In most places where you can use a literal (like 354 or 1039202), you can also use a scalar sub-query, a SELECT statement, enclosed in parentheses, that produces one column and (at most) one row.
    In your case, you can say:
    UPDATE  table_x
    SET     a_count = (SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = 4837)
    ,       a_sum = (SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = 4837
    WHERE   account = 4837;or, to make it more readable:
    UPDATE  table_x
    SET     a_count =
    ( SELECT count (*)
    FROM database.USAGE
    WHERE SERVICE_TYPE = 'C'
    AND ACCOUNT = 4837
    ,       a_sum =
    ( SELECT sum (minutes)
    FROM database.USAGE
    WHERE SERVICE_TYPE = 'DA'
    AND ACCOUNT = 4837
    WHERE   account = 4837;By the way, why are you using double-quotes around 4837? If it's a string, enclose it in single quotes. If it's a number (which I'm assuming in my code), don't enclose it in anything.
    WARNING: scalar sub-queries are somewhat like duct tape: they're extremely useful in certain places, and those places account for about 1% of their use. The other 99% of the time, there's a better way to do things, though the better way may require more expertise.

  • Using plsql tables in select statement of report query

    Hi
    Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
    thanks in advance
    suresh

    hi,
    u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
    declare
    ur_file utl_file.file_type;
    my_result varchar2(250);
    begin
    ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
    utl_file.get_line(ur_file, my_result);
    dbms_output.put_line(my_result);
    utl_file.fclose(ur_file);
    end;
    make sure u have an entry in ur init.ora saying that your
    utl_file_dir = '\your directory where ur files reside'
    cheers!
    [email protected]

  • Slow query results for simple select statement on Exadata

    I have a table with 30+ million rows in it which I'm trying to develop a cube around. When the cube processes (sql analysis), it queries back 10k rows every 6 seconds or so. I ran the same query SQL Analysis runs to grab the data in toad and exported results, and the timing is the same, 10k every 6 seconds or so. r
    I ran an execution plan it returns just this:
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576       
         1 TABLE ACCESS STORAGE FULL TABLE DMSN.DS3R_FH_1XRTT_FA_LVL_KPI Cost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576  I'm not sure if there is a setting in oracle (new to the oracle environment) which can limit performance by connection or user, but if there is, what should I look for and how can I check it.
    The Oracle version I'm using is 11.2.0.3.0 and the server is quite large as well (exadata platform). I'm curious because I've seen SQL Server return 100k rows ever 10 seconds before, I would assume an exadata system should return rows a lot quicker. How can I check where the bottle neck is?
    Edited by: k1ng87 on Apr 24, 2013 7:58 AM

    k1ng87 wrote:
    I've notice the same querying speed using Toad (export to CSV)That's not really a good way to test performance. Doing that through Toad, you are getting the database to read the data from it's disks (you don't have a choice in that) shifting bulk amounts of data over your network (that could be a considerable bottleneck) and then letting Toad format the data into CSV format (process the data adding a little bottleneck) and then write the data to another hard disk (more disk I/O = more bottleneck).
    I don't know exedata but I imagine it doesn't quite incorporate all those bottlenecks.
    and during cube processing via SQL Analysis. How can I check to see if its my network speed thats effecting it?Speak to your technical/networking team, who should be able to trace network activity/packets and see what's happening in that respect.
    Is that even possible as our system resides off site, so the traffic is going through multiple networks.Ouch... yes, that could certainly be responsible.
    I don't think its the network though because when I run both at the same time, they both are still querying at about 10k rows every 6 seconds.I don't think your performance measuring is accurate. What happens if you actually do the cube in exedata rather than using Toad or SQL Analysis (which I assume is on your client machine?)

  • How to edit the records value fetched by select statement query in sqldever

    How to edit the records value fetched by select statement query in sqldever 2.1.1.
    EX-
    SELECT * FROM emp WHERE ename like 'Jaga%'
    Edited by: user9372056 on Aug 31, 2010 2:16 AM

    Hi,
    Although some forum members may be using that tool, there is still a dedicated forum for SQL Developer.
    SQL Developer
    Maybe your chances are better there.
    Regards
    Peter

  • Select query and Insert statement performance

    Hi all,
    Can anyone plz guide us on below problem I am facing ?
    1) One of the simple Insert statement runs very slow..What might be the reason? Its simple table without any LOBs ,LONG or so. Everything else in the DB works fine.
    2) one of the SELECT statement runs very slow. It selects all records (around 1000) from a table..How can i improve its performance?
    3)Which columns in the Master and its detail tables should be indexed to improve Query performance on them.
    Many Thanks
    Regards
    sandeep

    To get an answer to your questions you have to post some informations about your system:
    1. operating system
    2. RAM
    3. oracle version
    4. init.ora
    Thomas

  • Select Statement to query smallest ID

    <My_Table>
    ID
    PHOENIX005
    PHOENIX006
    PHOENIX007
    PHOENIX008
    TUCSON001
    TUCSON002
    TUCSON003
    TEMPE010
    TEMPE011
    TEMPE002
    CHANDLER030
    CHANDLER031
    CHANDLER032
    Whats the best way to write a select statement that would only bring back the IDs with the smallest numerical value? I ultimately want my Query to display:
    ID
    PHOENIX005
    TUCSON001
    TEMPE010
    CHANDLER030

    Or may be like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (
      2             select 'PHOENIX005' id from dual union all
      3             select 'PHOENIX006' from dual union all
      4             select 'PHOENIX007' from dual union all
      5             select 'PHOENIX008' from dual union all
      6             select 'TUCSON001' from dual union all
      7             select 'TUCSON002' from dual union all
      8             select 'TUCSON003' from dual union all
      9             select 'TEMPE010' from dual union all
    10             select 'TEMPE011' from dual union all
    11             select 'TEMPE002' from dual union all
    12             select 'CHANDLER030' from dual union all
    13             select 'CHANDLER031' from dual union all
    14             select 'CHANDLER032' from dual
    15            )
    16  select *
    17  from
    18  (
    19     select id, row_number()over(partition by trim(translate(id,'0123456789', rpad(' ',10))) order by
    20     to_number(trim(translate(id,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', rpad(' ',26)))) ) as rno
    21     from t
    22* ) where rno=1
    SQL> /
    ID                 RNO
    CHANDLER030          1
    PHOENIX005           1
    TEMPE002             1
    TUCSON001            1
    SQL>

  • Need help with select statement or query

    Not familiar with what to call it, but here is what i need...
    To give our analyst a better idea of warranty on some of our
    equipment, i
    would like to add to the page a column that displays if the
    device is still
    under warranty
    I currently capture the date the equipment was returned from
    repair, so what
    could i use within my select statement or query to display a
    warranty
    expiration date or display on the page...
    example :
    Returned from repair 10/20/2006 warranty expires on
    11/20/2006
    each equipment has different warranties, so i need a formula
    or something to
    say... device #1 has 60 day warranty ( so 10/20/2006 + 60days
    =
    12/19/2006 )
    I would imagine this to be a query
    Table 1 would contain the equipment type and warranty time
    Table 2 would contain the current status of the equipment
    Query would take the back from repair date + warranty =
    expiration date

    Simple. Join the two tables and create a derived column for
    the expiration date. The exact syntax is dependant on your DBMS, so
    check the manual for whichever you are using and look at the date
    functions. There will be a function that will allow you to add a
    number of date units (day, month, year, etc) to a date
    field.

  • Query regarding Oracle SQL select statement

    Hi,
    How does Oracle ensures a consistent snapshot with the select statement
    without locking the table. My question is summarized with an example below:
    1. At time T1, Oracle select statement is fired and is fetching the result.
    2. At time T2, some DML operation is performed on the same table on which
    the select was executed and a commit was fired.
    3. At time T3, The Oracle select statement (Step 1) completes.
    My question is whether the records of transaction at time T2 will be visible at time T3 or not?
    If "not", then does it mean that Oracle retrieves the rows from the time of last commit.
    I would also like to know if for the above mechanism, Oracle would make use of the rollback segemt to access the rows at a particular instant of time.
    TIA
    Regards,
    Raj

    This is called Read Consistency in the oracle. Its all about SCN before starting the transaction.
    Lets say
    1. T1 executs SELECT statement on EMP table.
    2. T2 made an update on the EMP and commited.
    But, T1 only still sees only old image of the data not the new one. This is called read consistency.
    You will be having two images in the buffer, one is consistent and changed image.
    When the T1 give SELECT statement it notes the SCN of the transaction. Read oracle document about read consistency.
    SJH.

  • Querying many tables at once from a select statement for specific values

    Hi all,
    I'm very new to PL/SQL and have a daunting task ahead of me. I'm pretty sure our database normalization scheme is all out of whack, which I dont have the experience to fix yet, but this is the task ahead of me without getting to change or fix our structure:
    in the universe has 1000+ tables.
    need--> Some of those tables have fields that contain a value that has to be changed.
    The only thing I have to go on is the column name will contain 'EMP'... but there is no specific naming convention for the column names.
    When I search on:
    select * from all_tab_columns where column_name like UPPER('%EMP%')
    It returns 750 rows. (So 750 rows = 750 columns in 500 different tables (some tables have 2 or more columns in it))
    tables names are random (table1, table2, etc).
    columns names are random with EMP in it (column1,column2,etc).
    I have 75 possible field values that I need to check each of those 750 columns for.
    Maybe this is too messy, but I'm looking at subqueries, joins, arrays, cursors, etc, anything to minimize the amount of work I have to do.
    I think this is too much to do a join with, but that seems to be what all the documentation is pointing me to.
    can you point me to a simple example of what i could
    write?
    the logic i see it would be
    run the select statement to grab the column names that meet EMP.
    one at a time, search each column in the corresponding table for the 75 values.
    return the results of rows for each column/table that meet one of the 75 unique values.
    I'll have to also update each of the 75 values to (used to be values 1, 2, 3 ... to new values X1, X2, X3, etc.)
    Any help at all would be very helpful,
    aspiring pl/sql programmer but having a rough time of it

    I think you're looking to do something like the following pseudocode:
    BEGIN
        FOR tblrec IN (SELECT table_name, column_name
                         FROM all_tab_columns
                        WHERE column_name LIKE '%EMP%')
        LOOP
            FOR rec IN (SELECT ROWID
                          FROM tblrec.table_name
                         WHERE REGEXP_LIKE(tblrec.column_name, '(expr1|expr2|...)')
            LOOP
                DBMS_OUTPUT.PUT_LINE(
                    'Found expression on ROWID ' || rec.rowid
                    || ' in column ' || tblrec.column_name
                    || ' on table ' || tblrec.table_name);
            END LOOP;
        END LOOP;
    END;

  • Hint in Update or Select Statement in an inline query ??

    Hi ,
    I had an update statement that will get the data from the inline select statement,now where can i can keep the hint ,either in update statement or in Select statement...
    Please let me know if my sample script is wrong or any better way to approach...Please assume that Salary table had millions of employee's salary records.
    update emp
    set salary = salary + (select /*+ full(a) parallel(a,4)  */ salary from Salary
                             where   experience > 5  and empno = 55 )
    where empno = 85Thanks
    Rede

    You would put the hint in the select statement as you have it, but it won't work until you alias your table name to "a" since that is how you are referencing it in the hint:
    update emp
    set salary = salary + (select /*+ full(a) parallel(a,4)  */ salary from Salary a
                             where   experience > 5  and empno = 55 )
    where empno = 85
    NOTE I added the "a" right after the Salary table name AND you can only do parallel updates on partitioned table, but the select will run in parallel to at least get the data for you quickly.
    To answer your other question about syntax, it is incorrect and there are a lot of ways to write it but a straight forward way would be to use the merge statement
    merge into emp e
    using (select /*+ full(s) parallel(s,4)  */ s.salary from salary s where s.experience > 5) s
    on (e.empno = s.empno)
    when matched then update
    set salary = s.salary;

Maybe you are looking for