Sub selects in a SQL statement

Hi, I have a query with an obsene amount of sub selects,
for example :
SELECT p.ID,
(select something from data where id = p.id) data1,
(select somelse from data2 where id = p.id) data2,
(select someelse from data3 where id = p.id) data3,
(select someelse from data4 where id = p.id) data4,
(select someelse from data5 where id = p.id) data5,
FROM property P
WHERE ..........
this query is taking a long time to process. Is there a more efficient way of doing such a statement?
thanks in advance

Gabe:
Since the original poster said "this query is taking a long time to process", I assumed that there was a one-to-one relationship between properties and each of the dataX tables, otherwise, as you pointed out, he would be complaining about ORA-01427: single-row subquery returns more than one row
In my union, I am returning a single column from each of the data tables (plus the id), and a NULL for each of the other columns in the in-line view. The MAX function just gets the single row for each column that actually has a value.
As a test case, I did:
CREATE TABLE properties AS
SELECT rownum id, object_name
FROM all_objects
WHERE rownum < 11;
CREATE TABLE data1 (id NUMBER, descr VARCHAR2(10));
INSERT INTO data1 VALUES(1, 'ONE');
INSERT INTO data1 VALUES(2, 'TWO');
INSERT INTO data1 VALUES(3, 'THREE');
CREATE TABLE data2 (id NUMBER, descr VARCHAR2(10));
INSERT INTO data2 VALUES(4, 'FOUR');
INSERT INTO data2 VALUES(5, 'FIVE');
INSERT INTO data2 VALUES(6, 'SIX');
CREATE TABLE data3 (id NUMBER, descr VARCHAR2(10));
INSERT INTO data3 VALUES(7, 'SEVEN');
INSERT INTO data3 VALUES(8, 'EIGHT');
INSERT INTO data3 VALUES(9, 'NINE');The original version as posted retrieves:
SQL> SELECT p.id, p.object_name,
  2         (SELECT descr FROM data1 WHERE id = p.id) data1,
  3         (SELECT descr FROM data2 WHERE id = p.id) data2,
  4         (SELECT descr FROM data3 WHERE id = p.id) data3
  5  FROM properties p
  6  ORDER BY p.id;
        ID OBJECT_NAME                    DATA1      DATA2      DATA3
         1 TAB$                           ONE
         2 I_IND1                         TWO
         3 I_COBJ#                        THREE
         4 USER$                                     FOUR
         5 I_OBJ1                                    FIVE
         6 I_PROXY_ROLE_DATA$_2                      SIX
         7 BOOTSTRAP$                                           SEVEN
         8 I_ICOL1                                              EIGHT
         9 UNDO$                                                NINE
        10 PROXY_ROLE_DATA$
10 rows selected.
Statistics
          0  recursive calls
          0  db block gets
         93 consistent gets
          0  physical reads
          0  redo size
       1000  bytes sent via SQL*Net to client
        655  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
         10  rows processedBut, it does a SELECT (hopefully indexed) of data1, data2, and data3 for each row in properties. Minimally, 9 gets per row of properties (index root, index leaf, table row for each of data1, data2, data3) without even getting any data from properties.
My query returns:
SQL> SELECT p.id, p.object_name, a.data1, a.data2, a.data3
  2  FROM properties p,
  3       (SELECT id, MAX(data1) data1, MAX(data2) data2, MAX(data3) data3
  4        FROM (SELECT id, descr data1, TO_CHAR(NULL) data2, TO_CHAR(NULL) data3
  5              FROM data1
  6              UNION ALL
  7              SELECT id, TO_CHAR(NULL), descr, TO_CHAR(NULL)
  8              FROM data2
  9              UNION ALL
10              SELECT id, TO_CHAR(NULL), TO_CHAR(NULL), descr
11              FROM data3)
12        GROUP BY id) a
13  WHERE p.id = a.id(+)
14  ORDER BY p.id;
        ID OBJECT_NAME                    DATA1      DATA2      DATA3
         1 TAB$                           ONE
         2 I_IND1                         TWO
         3 I_COBJ#                        THREE
         4 USER$                                     FOUR
         5 I_OBJ1                                    FIVE
         6 I_PROXY_ROLE_DATA$_2                      SIX
         7 BOOTSTRAP$                                           SEVEN
         8 I_ICOL1                                              EIGHT
         9 UNDO$                                                NINE
        10 PROXY_ROLE_DATA$
10 rows selected.
Statistics
          0  recursive calls
          0  db block gets
         12 consistent gets
          0  physical reads
          0  redo size
       1000  bytes sent via SQL*Net to client
        655  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
         10  rows processedThe same result, but 1/8 of the gets. an outer join is also possible:
SQL> SELECT p.id, p.object_name, d1.descr data1, d2.descr data2, d3.descr data3
  2  FROM properties p, data1 d1, data2 d2, data3 d3
  3  WHERE p.id = d1.id(+) AND
  4        p.id = d2.id(+) AND
  5        p.id = d3.id(+)
  6  ORDER BY p.id;
        ID OBJECT_NAME                    DATA1      DATA2      DATA3
         1 TAB$                           ONE
         2 I_IND1                         TWO
         3 I_COBJ#                        THREE
         4 USER$                                     FOUR
         5 I_OBJ1                                    FIVE
         6 I_PROXY_ROLE_DATA$_2                      SIX
         7 BOOTSTRAP$                                           SEVEN
         8 I_ICOL1                                              EIGHT
         9 UNDO$                                                NINE
        10 PROXY_ROLE_DATA$
10 rows selected.
Statistics
          0  recursive calls
          0  db block gets
         12 consistent gets
          0  physical reads
          0  redo size
       1000  bytes sent via SQL*Net to client
        655  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
         10  rows processedSo, the same number of gets, and it saves one sort. But if the tables are large, multiple outer joins may not be as efficient as one outer join to the union all query.
HTH
John

Similar Messages

  • Select count(*) on sql statement returning zero when a matching row exists.

    Our account has an ANSI C application that checks for the existence a row on an Oracle table(s) by using the following SQL:
    int iCount = 0;
    EXEC SQL
    SELECT count(rownum) INTO :iCount
    FROM sys.all_tab_columns
    WHERE table_name IN
    (SELECT table_name FROM
    sys.all_synonyms
    WHERE upper(synonym_name) = upper(:szDestTable))
    AND upper(column_name) = upper(:szColumnName)
    AND owner = 'DBAUSER';
    The bind variables szDestTable and szColumnName are populated with values parsed from columns on another database table. This application is executed through out the day. Occasionally, the application will report a zero in the iCount when there should be a match. I have verified the szDestTable and szColumnName are populated with the correct values which would find a match and they are correct. To make matters even stranger, the application will parse the same input values and find a match (as it should). At some point during the day, and it can be at any time, the application will NOT find a match on the same file, same values. Every subsequent execution of this application will not find a match on the same values. Once the database is brought down and started up in the evening for its normal backups, the application will find a match again on the same values. This problem does not occur every day. I could be a week or a week and a half between incidents.
    I printed the contents of the sqlca.sqqlerrm.sqlerrmc field to a log file. The sqlca.sqlerrm.sqlerrmc field reported an ORA-1405 bind variable was null when the iCount was reporting a zero. When I compiled this application, I set the Proc*C flag to UNSAFE_NULLS=yes since there are other bind variable in the application that can be NULL and that is ok.
    The above SQL is compiled into the C application using the Proc*C compiler. It is compiled using the Oracle 11.2.0.2 libraries. The application is executed against an Oracle 11.2.0.2 database. The database and application are executed on an HP/Unix 11.31 platform.
    This problem did not start occurring until our account went from Oracle 10.2 to Oracle 11.2. Recently, I have changed the SQL to perform a “SELECT COUNT(rownum)” instead of the “SELECT COUNT(*)”. I compiled the application and executed the new application with the SELECT COUNT(rownum) against the same database where the same application with the SELECT COUNT(*) was failing to find a row that actually existed. The application with the SELECT COUNT(rownum) found the matching row as it should have. The new application has been executing in production for about 10 days now without any problems against ten various Oracle 11.2 databases.
    Why would SELECT COUNT(*) and SELECT COUNT(rownum) be any different?

    This forum is about C programming in general, and about using Studio C in particular.
    Your question is about Oracle database programming. You are more likely to find a helpful answer in a forum about database programming. Start here:
    https://forums.oracle.com/forums/category.jspa?categoryID=18

  • SQL statements through web based decelopment approach

    Hi,
    I am using the web based development workbench. I wish to create, insert and select tables using SQL statements only and not through HDBD language. Please let me know how it is possible. as of now, i see a tutorial which makes use of the HDBD language constructs only.
    Thanks,
    Murali.

    Hi Murali,
    I assume you are using a HANA Trial instance on HANA Cloud Platform. Also I assume that you already managed the web-base development workbench there.
    If you are in the workbench, you can open the catalog view like this (Check for the "plus" symbol in the upper left corner):
    In the catalog view, then check the "SQL" Button, again in the upper left corner:
    You now have a shell to execute SQL directly.
    Please consider: If you are using a HANA Trial instance, certain queries might not work because of missing permissions.
    Best,
    Thomas.

  • A very slow select with sub selects sql statement on Oracle

    Hi,
    I'm moving an application from MySql to Oracle. The following select were very efficiently executed in MySql. In oracle its slow like a snail.
    Do anyone have a hint on how to speed it up?
    The slow part is the four sub selects in the select part. Removing them makes the select about 50 times faster on Oracle.
    Best Regards,
    Stephane
    select
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and (rr.relation_type_id = 'link' OR rr.relation_type_id = 'product')) as relationList,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'number') as relationNumber,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'title') as relationTitle,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'content') as relationText,
    d.*
    from document d,(
    select distinct r.document_id id
    from relation r
    where
    r.product_id = ?
    ) dd
    where d.id=dd.id

    You are accessing the relation-table too many times, so a rewrite to a query like this
    SQL> select dept.deptno
      2       , dept.dname
      3       , count(decode(job,'CLERK',1)) clerk
      4       , count(decode(job,'MANAGER',1)) manager
      5       , count(decode(job,'SALESMAN',1)) salesman
      6    from dept, emp
      7   where dept.deptno = emp.deptno (+)
      8   group by dept.deptno
      9       , dept.dname
    10  /
        DEPTNO DNAME               CLERK    MANAGER   SALESMAN
            10 ACCOUNTING              1          1          0
            20 RESEARCH                2          1          0
            30 SALES                   1          1          4
            40 OPERATIONS              0          0          0
    4 rijen zijn geselecteerd.will be worth the effort.
    If still not satisfied, you have to do some investigation, as described [url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]here
    Regards,
    Rob.

  • Delete statement that uses a sub-select with the statement in the cursor

    Hi all,
    How to write write a delete statement that uses a sub-select with the statement in the cursor?
    CURSOR excluded_dates IS         
           SELECT TO_TIMESTAMP(report_parameter_value, in_date_format_mask)
          INTO my_current_date_time
          FROM report_parameters
         WHERE report_parameters.report_parameter_id    = in_report_parameter_id
           AND report_parameters.report_parameter_group = 'DATE_TIME'
           AND report_parameters.report_parameter_name  = 'EXCLUDED_DATE';
    OPEN excluded_dates;
      LOOP
        FETCH excluded_dates INTO my_excluded_date;
        EXIT WHEN excluded_dates%NOTFOUND;
        DELETE FROM edr_rpt_tmp_inclusion_table
        WHERE TO_CHAR(date_time, 'mm/dd/yyyy') = TO_CHAR(my_excluded_date, 'mm/dd/yyyy');
      END LOOP;
      CLOSE excluded_dates;Thanks

    Hi,
    In such case I think is better to create a view an perform the delete using it. Example (using HR schema):
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> create or replace view v_employees as select * from employees where first_name like 'J%';
    View created
    SQL> select * from v_employees;
    EMPLOYEE_ID FIRST_NAME           LAST_NAME                 EMAIL                     PHONE_NUMBER         HIRE_DATE   JOB_ID         SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
            110 John                 Chen                      JCHEN                     515.124.4269         28/09/1997  FI_ACCOUNT    8200,00                       108           100
            112 Jose Manuel          Urman                     JMURMAN                   515.124.4469         07/03/1998  FI_ACCOUNT    7800,00                       108           100
            125 Julia                Nayer                     JNAYER                    650.124.1214         16/07/1997  ST_CLERK      3200,00                       120            50
            127 James                Landry                    JLANDRY                   650.124.1334         14/01/1999  ST_CLERK      2400,00                       120            50
            131 James                Marlow                    JAMRLOW                   650.124.7234         16/02/1997  ST_CLERK      2500,00                       121            50
            133 Jason                Mallin                    JMALLIN                   650.127.1934         14/06/1996  ST_CLERK      3300,00                       122            50
            139 John                 Seo                       JSEO                      650.121.2019         12/02/1998  ST_CLERK      2700,00                       123            50
            140 Joshua               Patel                     JPATEL                    650.121.1834         06/04/1998  ST_CLERK      2500,00                       123            50
            145 John                 Russell                   JRUSSEL                   011.44.1344.429268   01/10/1996  SA_MAN       14000,00           0,40        100            80
            156 Janette              King                      JKING                     011.44.1345.429268   30/01/1996  SA_REP       10000,00           0,35        146            80
            176 Jonathon             Taylor                    JTAYLOR                   011.44.1644.429265   24/03/1998  SA_REP        8600,00           0,20        149            80
            177 Jack                 Livingston                JLIVINGS                  011.44.1644.429264   23/04/1998  SA_REP        8400,00           0,20        149            80
            181 Jean                 Fleaur                    JFLEAUR                   650.507.9877         23/02/1998  SH_CLERK      3100,00                       120            50
            186 Julia                Dellinger                 JDELLING                  650.509.3876         24/06/1998  SH_CLERK      3400,00                       121            50
            189 Jennifer             Dilly                     JDILLY                    650.505.2876         13/08/1997  SH_CLERK      3600,00                       122            50
            200 Jennifer             Whalen                    JWHALEN                   515.123.4444         17/09/1987  AD_ASST       4400,00                       101            10
    16 rows selected
    SQL> delete from v_employees where hire_date >= to_date('01/06/1998', 'dd/mm/yyyy');
    2 rows deleted
    SQL> regards,

  • Stuck on CONNECT_BY ... PRIOR statement / sub-select Query

    I am trying to generate a list of customisations made to our eBusiness system.
    I'm using this example as a starting point:
    SELECT *
       FROM applsys.jdr_paths jp1
      WHERE UPPER(jp1.path_name) = 'CUSTOMIZATIONS'
        AND jp1.path_docid BETWEEN 18000 AND 18700;
    _NAME                                                    PATH_DOCID PATH_OWNER_DOCID PATH_TYPE                        PATH_SEQ PATH_XML_V PATH_XML_E CREATED_BY                     CREATION_ LAST_UPDATED_BY                LAST_UPDA LAST_UPDATE_LOGIN
    customizations                                                18479             1650 PACKAGE                                -1                       1                              24-SEP-05 1                              24-SEP-05 1
    customizations                                                18665            18663 PACKAGE                                -1                       1                              24-SEP-05 1                              24-SEP-05 1
    customizations                                                18010            18009 PACKAGE                                -1                       1                              24-SEP-05 1                              24-SEP-05 1I can then use this to extract the full path - for example, using the example above, the "PATH_OWNER_DOCID" = 18663:
    SELECT     LEVEL
             , SYS_CONNECT_BY_PATH(p.path_name, '/') PATH
             , p.path_docid
          FROM (SELECT jp.path_name
                     , jp.path_seq
                     , jp.path_docid
                     , jp.path_owner_docid
                  FROM applsys.jdr_paths jp) p
    CONNECT BY path_docid = PRIOR path_owner_docid
    START WITH p.path_docid = 18665;
    LEVEL     PATH                                                                  PATH_DOCID
    1     /customizations                                                          18665     
    2     /customizations/webui                                                  18663     
    3     /customizations/webui/pagesetup                                          18661     
    4     /customizations/webui/pagesetup/printmgmt                          18660     
    5     /customizations/webui/pagesetup/printmgmt/bpa                          10174     
    6     /customizations/webui/pagesetup/printmgmt/bpa/ar                  10173     
    7     /customizations/webui/pagesetup/printmgmt/bpa/ar/apps                  2     
    8     /customizations/webui/pagesetup/printmgmt/bpa/ar/apps/oracle          1What I'd really like to do is to include the bottom most path (i.e. the most detailed, full path (path_docid = 1 in the e.g. above) in the first SQL statement.
    That way, against each customisation, listed via this:
    SELECT *
       FROM applsys.jdr_paths jp1
      WHERE UPPER(jp1.path_name) = 'CUSTOMIZATIONS'
        AND jp1.path_docid BETWEEN 18000 AND 18700;I would like to include, possibly via a sub-select, the full path of the customisation - not all of the other lines leading up to the full path, just the full path itself.
    But I can't work out how to combine the 2 SQLs, assuming it can be done at all.
    Any advice much appreciated.
    Thanks!

    If understand your question right... Just a MAX would work.
    select (SYS_CONNECT_BY_PATH(object_name, '/'))
    from
    select object_name, rownum lv
           from all_objects
       where rownum <= 5
       ) t
        START WITH lv = 1
       CONNECT BY PRIOR lv = lv - 1
    (SYS_CONNECT_BY_PATH(OBJECT_NAME,'/'))                                         
    /WRH$_SERVICE_WAIT_CLASS_PK                                                    
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS                            
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK     
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK/WRH$_SYS_TIME_MODEL
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK/WRH$_SYS_TIME_MODEL/WRH$_OSSTAT_PK
    5 rows selected.
    select max(SYS_CONNECT_BY_PATH(object_name, '/'))
    from
    select object_name, rownum lv
           from all_objects
       where rownum <= 5
       ) t
        START WITH lv = 1
       CONNECT BY PRIOR lv = lv - 1
    MAX(SYS_CONNECT_BY_PATH(OBJECT_NAME,'/'))                                      
    /WRH$_SERVICE_WAIT_CLASS_PK/WRH$_SERVICE_WAIT_CLASS/WRH$_SYS_TIME_MODEL_PK/WRH$_SYS_TIME_MODEL/WRH$_OSSTAT_PK
    1 row selected.vr
    Sudhakar B.

  • Merge statement - update multiple columns from a single sub-select

    Is it possible to write in 10gR2, a MERGE statement, with UPDATE for multiple columns from a single sub_select?
    like this:
    MERGE INTO tableA
    using ( select * from temp) tmp
    on( tableA. col1 = tmp.col1)
    when matched then
    update set  ( tableA.col5,
                       tableA.col6,
                       tableA.col7) = ( select sum(col2), sum(col3), sum(col5)
                                                                                 from tableX
                                                                                where tableX.col1 = tableA.col1...)

    Hi,
    The USING clause is not a sub-query, so it can't reference columns from tables that are not in it.
    Include tableA in the USING clause if you really need to refer to it there. (It's not obvious that you do.)
    As always, it helps if you post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data (In the case of a DML statement, such as MERGE, this will be the state of the tables when everything is finished.)
    (4) Your best attempt so far (formatted)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, tables in scott schema, or views in the data dictionary), then you can omit (2).
    Formatted tabular output is okay for (3).

  • USING MULTIPLE SELECT VARIABLE IN A SQL STATEMENT

    In HTMLDB, the value of the parameter of a multiple select box is colon delimited(ie P6_Name = Smith:Jones:Burke). Is there an easy way to use this parameter in a SQL statement?
    Example
    Select *
    from names
    where
    Name=P6_Name
    Select *
    from names
    where
    Name IN ('Smith','Jones','Burke')
    Thank you

    Thank you for your response! I'm an idiot. It didn't make sense to me because your talking about a <i>multi-select</i> variable and I was thinking about a <i>select-list</i> variable. My problem is that I need to assign a list of values to one select list item.
    <br>
    For example:
    <br>
    SELECT * FROM EMPLOYEE
    WHERE EMPLOYEE_TYPE IN ( :SELECT_LIST_RETURN_VALUE );
    <br><br>
    With the select list as
    <br><br>
    Display value = All Types, Some Types, One Specific Type<br>
    Return Value = (Type1, type2, type3), (type1, type2), (type3)
    <br><br>
    I've just started in all of this so I'd imagine that I'm probably going about it wrong.

  • Sub-Select SQL query in Oracle BI Answers

    Hi
    What's the proper usage of Sub-Select SQL query in Oracle BI Answers Version Oracle Business Intelligence 10.1.3.2.1?
    I get [SQL_STATE: HY000] [nQSError: 10058] A general error has occured when trying to Sub Select query like:
    itemno = (SELECT MIN(orders.itemno) FROM mydatabase where rownum < 2 order by orders.itemno)

    Maybe the best is to create a new physical and logical object for your sub-select and join this with your current objects.

  • Selection Screen Parameters in SQL statements

    Very new ABAP programmer here, so sorry if this is a really dumb question.
    I'm trying to use my selection screen parameters to limit what is pulled in by my SQL statement (which seems to me to be a very logical thing to do).  But I'm having a problem, that when no values are entered in the parameters, no data is returned in the table instead of all the data being returned.
    Here is the code I have now:
      SELECT cname1 akostl aorgeh asname apernr bbegda bendda bstatu
             bconfl bmedcf breasn breman b~rqday
      INTO CORRESPONDING FIELDS OF TABLE it_record
       FROM ( ( pa0001 AS a
          INNER JOIN pa0672 AS b ON bpernr = apernr )
          INNER JOIN t500p AS c ON cpersa = awerks )
      WHERE  b~reman in so_reman
        AND a~kostl  in so_kostl
        AND a~orgeh = p_orgeh
        AND b~begda = p_begda
        AND b~statu = p_statu
        AND b~confl = p_confl
        AND b~medcf = p_medcf
        AND b~reasn = p_reasn
        AND b~rqday = p_rqday
        AND c~name1 = p_name1.
    Can anyone tell me what I'd need to do to make it return properly?

    When you use parameters and no value is entered, it is treated as initial value. and the select statement looks for the initial values for those fields in the tabl;e...
    you can make the parameters mandatory..then the user would be forced to enter something....
    also you could do the following..
    instead of parameters, use select-options with the addition no intervals and no extension, then practically it looks like a parameter but internally it is a select-option...
    and in the select statement, give conditions like....field1 in <s_option name>....in this case if the user is not entering a value ...it is treated as *...
    Thnaks & Regards,
    Renjith

  • Select the progress of an another sql statement

    What I want to do is to monitor the progress of a sql statement which takes a long time. How many percent of the statement is already done.
    I know there is the possibility to do this with a query.
    But I can' t remember how to do this exactly.
    Can somebody help me?
    Thanks a lot!

    Here is a SELECT that I usually run:
    COLUMN MODULE FOR A20
    COLUMN OPNAME FOR A20
    COLUMN SOFAR FOR 999999999999
    COLUMN TOTALWORK FOR 999999999999
    COLUMN UNITS FOR A20
    COLUMN REMAINING FOR 999999999
    COLUMN ELAPSED FOR 999999999
    SELECT
               S.SID
              ,S.AUDSID
              ,S.OSUSER
              ,S.MODULE
              ,L.OPNAME
              -- ,TARGET                
              -- ,TARGET_DESC           
              -- ,CONTEXT               
              ,L.SOFAR
              ,L.TOTALWORK
              ,L.UNITS
              ,L.START_TIME            
              ,L.LAST_UPDATE_TIME
              ,L.TIME_REMAINING REMAINING
              ,L.ELAPSED_SECONDS ELAPSED
              -- ,MESSAGE               
              -- ,USERNAME              
              ,L.SQL_ADDRESS
              -- ,SQL_HASH_VALUE        
              -- ,QCSID       
              -- ,A.SQL_TEXT
         FROM V$SESSION_LONGOPS L
              ,V$SESSION S
              -- , V$SQLAREA A
         WHERE L.TIME_REMAINING <> 0
              AND L.SID = S.SID
              AND L.SERIAL# = S.SERIAL#
    ;Note that V$SESSION_LONGOPS as a rule does not show long operations which take a lot of index range scans - this is not a "long operation"

  • In a SQL statement, the SELECT clause is used to

    In a SQL statement, the SELECT clause is used to select
    (a) columns
    (b) rows
    (c) tables
    (d) none of the above
    can any one help Immediately

    Is used to select rows of specified column...
    SELECT column_name(s) FROM table_name

  • Dynamic select sql statement

    Hi currently i have a problem with the sql statement.
    The field name and the table name of the sql statement will depend on what the user input. We need to find out what records is in tableA columnA and not in tableB columnB.
    Below is my sql statement:
    SELECT * FROM (TABLEA) INTO TABLE ITABA
    WHERE (COLUMNA)
    NOT IN ( SELECT (COLUMNB) FROM (TABLEB) ).
    =============================================
    ColumnA = "the user input the field name"
    TableA = " the user input the table name"
    TableB = " the user input the table name"
    The problem lies at the WHERE clause. The system generate a sql error which says "unable to find the field name".

    Hi,
    Check the following code:
    For dynamic table name....
    REPORT demo_select_dynamic_database .
    DATA wa TYPE scarr.
    DATA name(10) TYPE c VALUE 'SCARR'.
    SELECT *
    INTO wa
    FROM (name) CLIENT SPECIFIED
    WHERE mandt = '000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDSELECT.
    For dynamic field list
    REPORT demo_select_dynamic_columns .
    DATA: itab TYPE STANDARD TABLE OF spfli,
                wa LIKE LINE OF itab.
    DATA: line(72) TYPE c,
    list LIKE TABLE OF line(72).
    line = ' CITYFROM CITYTO '.
    APPEND line TO list.
    SELECT DISTINCT (list)
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM spfli.
    IF sy-subrc EQ 0.
    LOOP AT itab INTO wa.
    WRITE: / wa-cityfrom, wa-cityto.
    ENDLOOP.
    ENDIF.
    Regards,
    Bhaskar

  • Patterns to execute a SQL Statement from a Droplet (select)

    Hi,
    I need to perform a query on a table, Example: select * from ARF_QUERY "the database used is Oracle. I would like to know if the atg has some
    standard method to perform this database connection and execute the SQL statement from a Droplet (select).
    Thank.

    I dont think there is any generic droplet to run a select query directly against a table.
    However, there are various lookup droplets available that run on the repositories.
    Like /atg/targeting/RepositoryLookup droplet. you can run it for specific id or for all.
    You might want to have a look at it in documentation of how exactly to use it.
    Thanks

  • SQL statement: select maximal 20 rows of table

    Hi everybody,
    I know taht this is no dedidcated XI question.
    But, does anybody the sql statement for selecting maximal (e.g. 20) rows?
    Regards Mario

    Hi Mario,
    u can use direct SQL Statement with
    action= SQL_QUERY
    Look to <a href="http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm">Document Formats for the Receiver JDBC Adapter</a>
    Regards,
    Udo

Maybe you are looking for

  • ICloud not restoring my photos in the camera roll. HELP ! :(

    Apparently I had to reset my iphone but before doing this I checked if my back up was updated with icloud and IT WAS! After sucessfully completing the reset process I found out that all my stuff is back (contacts, notes, reminders etc.) EXCEPT the ph

  • How to save file on server folder

    hi i was trying to save file in my specify folder path. but it cann't save on than location. if i will not specify path then it directly save file on "c:program files\tomcat5.7\bin\mytextfile.txt" if i will specify perfect path "c://systemfile//mytex

  • JVM Error 517 - Can I back up my data?

    My blackberry is stuck in the JVM 517 error loop and I desperately need to make a backup of my organizer data (particularly of my calendar, to do list and notes). Any suggestions on how to accomplish this would be greatly appreciated. I am unable to

  • [CS3 JS]  Exchange Character Style Problem!

    Hello experienced JS people, The situation is as follows - I have a document that MAY have the Character Style 'A'. If this were to be true - then I'd like to exchange it for Character Style 'B'. Sounds simple doesn't it.... It's KILLING ME! This mus

  • No POWL object types are assigned to you. Please inform your system admin

    Hi experts, We are on SRM 7.0 and ECC 6.0. We are using netweaver 7.0 (SP7) for our portal instance. SSO, UWL etc have been configured in the Portal. Now when the user logs in to create a shopping cart and clicks on the Employee Self Service link, he