SQL query has strange behavior on sql server 2014

Hi All,
I have a very weird situation where a front end entity framework query (cannot be modified easily) made up of SQL views that are used in subquery format. It generally runs within few seconds but there are times in the day when query just keep on going and
sometimes start spitting results very slowly and at other times no result but keep on executing. Sysprocesses table shows sos_scheduler_yield wait type when query is running and not returning results. This behavior started on the query since the database was
upgraded (migrated) from sql 2005 clustered enterprise instance to a new 2014 Enterprise clustered instance on a very powerful server.  This query is used by a batch process and what I have found that if we rebuild indexes on the database (takes
only 2 mins) , the query appears to be returning results as expected. No other solution is working at the moment. The query had no issue on older sql 2005 instance and I have tested it their a few times. I am assuming it is a SQL 2014 related issue and found
a fix on CU 5 for sos_scheduler_yield but it has not fixed the issue. At this point SQL 2014 is on latest CU 6 as of last week and index rebuilt wis the only viable work around to get the query going without interruption.
Has anyone faced this issue on SQl 2014 or have some suggestions I can try. I can reproduce this error on at least two instances on SQL 2014. I have even tried setting max dop at server level to 1 and at half the total processors cores but to no avail. There
is a 750GB memory on the box.
Thanks
dba60
dba60

First of all, SOS_SCHEDULER_YIELD has nothing to do with the query as such. SQL Server has a co-operative operating system, which means that processes voluntary yields to permit other threads to executes. This sends them to the wait state SOS_SCHEDULER_YIELD.
If there is no other process executing, they are directly back in the game.
The problems with your query is most likely to be an issue with the query plan. It is not uncommon to see plan changes when you move from one version of SQL Server to another because of changes in the optimizer.
As Satish says, SQL 2014 has a new cardinality estimator (CE), which certainly can change the game. Check the compatibility level of the database. If the compat level is 120, you are using the new CE, else you are using the old one.
If the level is 120, the first check is to change it to 110 to see if this has any effect. 
But in the end you will have to work more with the query. Analyse it to see if it can be improved by adding indexes. You say said that this query generated by Entity Framework. Unfortunately, this is an indiciation of that the query is not the best and could
serve from a rewrite.
The ultimate rescue would be to freeze the plan when it runs well. I have some text about this here:
http://www.sommarskog.se/query-plan-mysteries.html#planguides
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Best way to spool DYNAMIC SQL query to file from PL/SQL

    Best way to spool DYNAMIC SQL query to file from PL/SQL [Package], not SqlPlus
    I'm looking for suggestions on how to create an output file (fixed width and comma delimited) from a SELECT that is dynamically built. Basically, I've got some tables that are used to define the SELECT and to describe the output format. For instance, one table has the SELECT while another is used to defined the column "formats" (e.g., Column Order, Justification, FormatMask, Default value, min length, ...). The user has an app that they can use to customize the output...which leaving the gathering of the data untouched. I'm trying to keep this formatting and/or default logic out of the actual query. This lead me into a problem.
    Example query :
    SELECT CONTRACT_ID,PV_ID,START_DATE
    FROM CONTRACT
    WHERE CONTRACT_ID = <<value>>Customization Table:
    CONTRACT_ID : 2,Numeric,Right
    PV_ID : 1,Numeric,Mask(0000)
    START_DATE : 3,Date,Mask(mm/dd/yyyy)The first value is the kicker (ColumnOrder) as well as the fact that the number of columns is dynamic. Technically, if I could use SqlPlus...then I could just use SPOOL. However, I'm not.
    So basically, I'm trying to build a generic routine that can take a SQL string execute the SELECT and map the output using data from another table to a file.
    Any suggestions?
    Thanks,
    Jason

    You could build the select statement within PL/SQL and open it using a cursor variable. You could write it to a file using the package 'UTL_FILE'. If you want to display the output using SQL*Plus, you could have an out parameter as a ref cursor.

  • How the SQL Query Parsing is processing inside SQL/PLSQL engine?

    Hi all,
    Can you explain how the SQL Query Parsing is processing inside SQL/PLSQL engine?
    Thanks,
    Sankar

    Sankar,
    Oracle Database concepts - Chapter 24..
    You will find the explanation required under the heading parsing.
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm

  • Pass the result of a SQL Query as table_name  for another SQL Query

    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    Thanks

    Naveen B wrote:
    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    ThanksYou should craete PL/SQL code with cursor which will accept a parameter and call that cursor inside the first one
    But if the first sql returns only one row, you can do it with simple sql code
    select * from (select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ')- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • SQL query against tables on MS SQL Server and Oracle using Oracle BI

    Hi All
    I have two databases Oracle and MS SQL Server. I want to write a query statement which will retrieve data from both databases and publish this data into one report. That is I want to join/merge data from tables in both database into one report with one SQL Statement something like:
    Select o.F1,o.F2, m.F1,m.F2
    from
    table@oracleServer o,
    table@microsoftSQLServer m
    where o.F1=m.F1;
    Can Oracle BI Publisher do this?
    Basically I want to query simultaneously two heterogeneous data sources in one SQL statement. Is there such a tool? I don't want to build a warehouse by moving data from SQL Server into Oracle or vice-versa. I don't want to duplicate data. I want to be able to query data at its source via 1 SQL statement.
    How would one go about doing such a thing?
    Many Thanks
    Kubilay.

    Hi Matt and Thomas
    Many thanks for your replies.
    Yes I have to do the join. Even worse I have to write an Aggregate query like this!
    Select o.F1,o.F2, m.F1,m.F2, count(*)
    from
    table@oracleServer o,
    table@microsoftSQLServer m
    where o.F1=m.F1
    group by o.F1,o.F2, m.F1,m.F2;
    These are 2 different systems (hardware & software) which actually do the same job, they produce transactions for a common business entity. Kind of, both sell tickets for the same ABC ferry company.
    I can not put them side by side on the dashboard, as I need to aggregate the data and present it maybe in a Oracle BI Report for Accounting and Financial reconciliation purposes.
    The truth is, as it is. I can't change it, is too late.
    I have to device a way to harvest both systems as they are. I don't want to move around data. I thought looking at Oracle BI I could write SQL against multiple Data Sources. I am struggling to find a way. As it seems that it can "SQL query" 1 data source at a time.
    I have been hinted on another forum (OracleTURK) to use Oracle Transparent Gateways and Generic Connectivity. http://download.oracle.com/docs/cd/B19306_01/server.102/b14232/toc.htm
    Shame, I have to pay licenses for OWB and Oracle Transparent Gateways. I thought DB vendors can do better. Why do I have to pay to access the other 50% of the market.
    I can understand the performance implications this might have. Because of it I might even be forced at the end to move data (ETL) into a separate database, slice it into partitions and manage it that way. Pitty because currenlty I only need one report out of these systems but seems like will be dear to get.
    Thank you for all your help.
    Kubilay

  • SQL query works in SSIS, SSMS/SQL server but fails in deployment?

    The SQL query in my execute sql task is correct. It works in SSIS and SSMS also. But, it fails when I deploy my package. The error -
    Code: 0xC002F210
    Source: MySQLTask Execute SQL Task Description: Executing the query
    "UPDATE [MyTable] SET MyCol..."
    failed with the following error: "Invalid object name 'MyTable'.".
    Possible failure reasons: Problems with the query "ResultSet" property
    not set correctly parameters not set correctly or connection not established
    correctly.
    What could be the reason for this error and how do I fix it ?
    Thanks.

    Does the database have the object [MyTable]?  What is the default schema for the user?  Is the table (assuming it exists) in the default schema for the user?
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com
    Yes, the DB has the object [MyTable]. The default schema is dbo, as given by SELECT SCHEMA_NAME()
    The table is in the default schema for the user as per - 
    SELECT * 
    FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_SCHEMA = SCHEMA_NAME() 
    AND  TABLE_NAME = 'MyTable'

  • SQL Query for Project Permission in Project Server 2010

    HI
    I have assign multiple users on multiple projects with different level permission, 
    The permission level is assign from Project Permission (icon ribbon in PWA 2010.)
    (1.Open the project within Project Professional or Project Web App,
    2.Edit and Save
    the project within Project Professional or Project Web App
    3.Edit Project
    Summary Fields within Project Professional or Project Web App
    4.Publish the
    project within Project Professional or Project Web App
    5.View the Project
    Summary in the Project Center
    6.View the Project
    Schedule Details in Project Web App.
    7.View the Project
    Site)
    Is there any SQL Query to find which user/resource is assign to which projects and what above permission is assign.
    Thanks 
    Farhan
    farhan

    Hi Farhan,
    Please find the SQL below below which will give project permission users:
    select RES_SECURITY_GUID from ProjectServer_Published.dbo.MSP_RESOURCES where RES_UID = '37A56C30-34DE-417B-95A8-42FBA6F47565'
    select PROJ_NAME  from ProjectServer_Published.dbo.MSP_PROJECTS where PROJ_UID in (
    select distinct c.PROJ_UID from ProjectServer_Published.dbo.MSP_WEB_SECURITY_PROJECT_CATEGORIES c
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_SP_CAT_RELATIONS pcr on pcr.WSEC_CAT_UID = c.WSEC_CAT_UID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_SP_CAT_PERMISSIONS pcp on pcp.WSEC_REL_UID = pcr.WSEC_REL_UID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_GROUP_MEMBERS gm on gm.WSEC_GRP_GUID = pcr.WSEC_SP_GUID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_SECURITY_FEATURES_ACTIONS AS SFA ON SFA.WSEC_FEA_ACT_UID = pcp.WSEC_FEA_ACT_UID
              INNER JOIN ProjectServer_Published.dbo.MSP_WEB_CONVERSIONS AS CONV ON CONV.CONV_VALUE = SFA.WSEC_FEA_ACT_NAME_ID where (1=1)
    And (CONV.LANG_ID = 1033) and gm.WRES_GUID = '2F5512D4-F561-43AF-AB7B-A189B0B9B6E8') -- Replace with above returned RES_SECURITY_GUID
    Vivek

  • SQL Developer generates strange trace files on server

    Hello out there,
    I observed the generation of some strange trace files on the database server (Oracle 11.0.2.0.2 64bit on Win 2008R2).
    Whenever I start SQL Developer (3.2.20.09.87 64bit with JDK 1.7.0_17 64bit on Win7 64bit) for each connection I defined one trace file like this is generated:
    Trace file C:\ORACLE\diag\rdbms\ora\ora\trace\ora_ora_8500.trc
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    Windows NT Version V6.1 Service Pack 1
    CPU                 : 2 - type 8664, 2 Physical Cores
    Process Affinity    : 0x0x0000000000000000
    Memory (Avail/Total): Ph:990M/3959M, Ph+PgF:3743M/7918M
    Instance name: ora
    Redo thread mounted by this instance: 1
    Oracle process number: 23
    Windows thread id: 8500, image: ORACLE.EXE (SHAD)
    *** 2013-03-06 08:04:13.842
    *** CLIENT ID:() 2013-03-06 08:04:13.842
    *** SERVICE NAME:() 2013-03-06 08:04:13.842
    *** MODULE NAME:() 2013-03-06 08:04:13.842
    *** ACTION NAME:() 2013-03-06 08:04:13.842
    Breaking the connection before proto/dty negotiation, error raised 3113I enabled listener log to find out the origin of this and it contains lines like the following:
    06-MRZ-2013 08:04:13 * (CONNECT_DATA=(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))(SERVICE_NAME=ora.vu)(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.36.143)(PORT=49320)) * establish * ora.vu * 0
    06-MRZ-2013 08:04:13 * (CONNECT_DATA=(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))(SERVICE_NAME=ora.vu)(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.36.143)(PORT=49322)) * establish * ora.vu * 0
    06-MRZ-2013 08:04:13 * (CONNECT_DATA=(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))(SERVICE_NAME=ora.vu)(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.36.143)(PORT=49323)) * establish * ora.vu * 0
    06-MRZ-2013 08:04:13 * (CONNECT_DATA=(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))(SERVICE_NAME=ora.vu)(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.36.143)(PORT=49325)) * establish * ora.vu * 0
    06-MRZ-2013 08:04:14 * (CONNECT_DATA=(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))(SERVICE_NAME=ora.vu)(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.36.143)(PORT=49329)) * establish * ora.vu * 0
    06-MRZ-2013 08:04:14 * (CONNECT_DATA=(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))(SERVICE_NAME=ora.vu)(CID=(PROGRAM=null)(HOST=__jdbc__)(USER=null))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.36.143)(PORT=49331)) * establish * ora.vu * 0The IP address is mine and I have excatly 6 connections defined for that server. On other servers, similar trace files are generated, one for each connection in my SQL Developer.
    This also occurred with JDK 1.6 so I don't think it's a Java issue.
    Besides the generation of the trace files there seem to be no other problems.
    Any ideas?

    Hi,
    I think Srini is probably correct. The noted bug applies to 11.2.0.1 and up, is fixed in 12c, and included in an 11.2.0.3 patch. However the version of SQL Developer also affects the creation of trace files on product startup (prior to any user initiated db connect attempts).
    For example,
    A. SQL Developer 3.1.07.42 - no such trace files created.
    B. SQL Developer 3.2.20.09.87 - such trace files created for 11.2.0.1 connections, but not 10g XE or 12c connections.
    So I presume an OCIServerAttach call got added in 3.2.2, not sure in support of which feature, but the bug will only impact users of 11.2.0.1, 11.2.0.2, and unpatched 11.2.0.3 DB releases.
    Regards,
    Gary
    SQL Developer Team

  • Tuning (SQL Query has radically different Buffer GETS in each instance)

    I have been noticing that on Node2 of my 10.2.0.3 RAC cluster CPU has been running 90% for the past couple of days and on Node1 we are at the normal 20-30%. I was comparing AWR for both instances and noticed that the same exact SQL was showing different GETS on each instance.
    Both Instances are configured exactly the same. SGA 3GB, 2 dual core 1.5Ghz CPU on Solaris 10.
    AWR For Node 1
    SQL ordered by Gets
    Resources reported for PL/SQL code includes the resources used by all SQL statements called by the code.
    Total Buffer Gets: 8,199,224
    Captured SQL account for 94.2% of Total
    Buffer Gets  Executions  Gets per Exec  %Total CPU Time (s) Elapsed Time (s) SQL Id SQL Module SQL Text
    4,834,470 16,465 293.62 58.96 442.34 459.42 cs3w0nz7uanhc    BEGIN HRW_EC_QUERY.CHECK_STUDE...
    4,561,082 16,469 276.95 55.63 411.10 430.16 6vbpbvfburc4x    SELECT COUNT(SECURE_PROGRAMS.P... AWR For Node 2
    Buffer Gets  Executions  Gets per Exec  %Total CPU Time (s) Elapsed Time (s) SQL Id SQL Module SQL Text
    219,779,881 9,306 23,617.01 99.26 11791.62 32202.99 cs3w0nz7uanhc    BEGIN HRW_EC_QUERY.CHECK_STUDE...
    219,320,634 9,302 23,577.79 99.05 11760.22 32137.23 6vbpbvfburc4x    SELECT COUNT(SECURE_PROGRAMS.P... Gets on Node 2 are about 45 times what they are on node 1. We are using bind variables in the SQL. The statements are completely identical. Anyone seen this before?
    Thanks,
    Brian

    All parameters are the same between instances. Here is the result of the query.
    PLAN_TABLE_OUTPUT                                                                                                                          
    SQL_ID 6vbpbvfburc4x                                                                                                                       
    SELECT COUNT(SECURE_PROGRAMS.PROG_ID) FROM SECURE_PROGRAMS,HRW_EC_ACTIVE_ITEM, (SELECT ACTIVE_ITEM_ID                                      
    FROM TABLE(CAST(:B1 AS HRW_EC_ACTIVE_ITEM_ID_TABLE_T)) ) T WHERE HRW_EC_ACTIVE_ITEM.ACTIVE_ITEM_ID =                                       
    T.ACTIVE_ITEM_ID AND HRW_EC_ACTIVE_ITEM.SPROG_ID = SECURE_PROGRAMS.PROG_ID AND                                                             
    SECURE_PROGRAMS.STUDENT_RESOURCES_URL = :B2                                                                                                
    Plan hash value: 25280318                                                                                                                  
    | Id  | Operation                           | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |                          
    |   0 | SELECT STATEMENT                    |                           |       |       |   730 (100)|          |                          
    |   1 |  SORT AGGREGATE                     |                           |     1 |    57 |            |          |                          
    |   2 |   HASH JOIN                         |                           |   116 |  6612 |   730   (1)| 00:00:09 |                          
    |   3 |    COLLECTION ITERATOR PICKLER FETCH|                           |       |       |            |          |                          
    |   4 |    NESTED LOOPS                     |                           | 48596 |  2610K|   705   (1)| 00:00:09 |                          
    |   5 |     INDEX RANGE SCAN                | SECURE_PROGRAMS_IDX_04    |     4 |    76 |     2   (0)| 00:00:01 |                          
    |   6 |     INDEX RANGE SCAN                | HRW_EC_ACTIVE_ITEM_IDX_03 | 10984 |   386K|   176   (1)| 00:00:03 |                          
    Query Block Name / Object Alias (identified by operation id):                                                                              
       1 - SEL$62A3881B                                                                                                                        
       5 - SEL$62A3881B / SECURE_PROGRAMS@SEL$1                                                                                                
       6 - SEL$62A3881B / HRW_EC_ACTIVE_ITEM@SEL$1                                                                                             
    SQL_ID 6vbpbvfburc4x                                                                                                                       
    SELECT COUNT(SECURE_PROGRAMS.PROG_ID) FROM SECURE_PROGRAMS,HRW_EC_ACTIVE_ITEM, (SELECT ACTIVE_ITEM_ID                                      
    FROM TABLE(CAST(:B1 AS HRW_EC_ACTIVE_ITEM_ID_TABLE_T)) ) T WHERE HRW_EC_ACTIVE_ITEM.ACTIVE_ITEM_ID =                                       
    T.ACTIVE_ITEM_ID AND HRW_EC_ACTIVE_ITEM.SPROG_ID = SECURE_PROGRAMS.PROG_ID AND                                                             
    SECURE_PROGRAMS.STUDENT_RESOURCES_URL = :B2                                                                                                
    Plan hash value: 219484150                                                                                                                 
    | Id  | Operation                            | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |                         
    |   0 | SELECT STATEMENT                     |                           |       |       |  4845 (100)|          |                         
    |   1 |  SORT AGGREGATE                      |                           |     1 |    57 |            |          |                         
    |   2 |   HASH JOIN                          |                           |  2066 |   115K|  4845   (2)| 00:00:59 |                         
    |   3 |    INDEX RANGE SCAN                  | SECURE_PROGRAMS_IDX_04    |    79 |  1501 |     2   (0)| 00:00:01 |                         
    |   4 |    HASH JOIN                         |                           |  3284 |   121K|  4843   (2)| 00:00:59 |                         
    |   5 |     COLLECTION ITERATOR PICKLER FETCH|                           |       |       |            |          |                         
    |   6 |     INDEX FAST FULL SCAN             | HRW_EC_ACTIVE_ITEM_IDX_03 |  1373K|    47M|  4803   (2)| 00:00:58 |                         
    Query Block Name / Object Alias (identified by operation id):                                                                              
       1 - SEL$62A3881B                                                                                                                        
       3 - SEL$62A3881B / SECURE_PROGRAMS@SEL$1                                                                                                
       6 - SEL$62A3881B / HRW_EC_ACTIVE_ITEM@SEL$1                                                                                             
    Note                                                                                                                                       
       - SQL profile "SYS_SQLPROF_014414387fd00001" used for this statement                                                                    
    SQL_ID 6vbpbvfburc4x                                                                                                                       
    SELECT COUNT(SECURE_PROGRAMS.PROG_ID) FROM SECURE_PROGRAMS,HRW_EC_ACTIVE_ITEM, (SELECT ACTIVE_ITEM_ID                                      
    FROM TABLE(CAST(:B1 AS HRW_EC_ACTIVE_ITEM_ID_TABLE_T)) ) T WHERE HRW_EC_ACTIVE_ITEM.ACTIVE_ITEM_ID =                                       
    T.ACTIVE_ITEM_ID AND HRW_EC_ACTIVE_ITEM.SPROG_ID = SECURE_PROGRAMS.PROG_ID AND                                                             
    SECURE_PROGRAMS.STUDENT_RESOURCES_URL = :B2                                                                                                
    Plan hash value: 740005210                                                                                                                 
    | Id  | Operation                           | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |                          
    |   0 | SELECT STATEMENT                    |                           |       |       |  4845 (100)|          |                          
    |   1 |  SORT AGGREGATE                     |                           |     1 |    57 |            |          |                          
    |   2 |   HASH JOIN                         |                           |     7 |   399 |  4845   (2)| 00:00:59 |                          
    |   3 |    COLLECTION ITERATOR PICKLER FETCH|                           |       |       |            |          |                          
    |   4 |    HASH JOIN                        |                           |  2992 |   160K|  4821   (2)| 00:00:58 |                          
    |   5 |     INDEX RANGE SCAN                | SECURE_PROGRAMS_IDX_04    |    33 |   627 |     2   (0)| 00:00:01 |                          
    |   6 |     INDEX FAST FULL SCAN            | HRW_EC_ACTIVE_ITEM_IDX_03 |  1373K|    47M|  4803   (2)| 00:00:58 |                          
    Query Block Name / Object Alias (identified by operation id):                                                                              
       1 - SEL$62A3881B                                                                                                                        
       5 - SEL$62A3881B / SECURE_PROGRAMS@SEL$1                                                                                                
       6 - SEL$62A3881B / HRW_EC_ACTIVE_ITEM@SEL$1                                                                                             
    Note                                                                                                                                       
       - SQL profile "SYS_SQLPROF_014414387fd00001" used for this statement                                                                    
    SQL_ID 6vbpbvfburc4x                                                                                                                       
    SELECT COUNT(SECURE_PROGRAMS.PROG_ID) FROM SECURE_PROGRAMS,HRW_EC_ACTIVE_ITEM, (SELECT ACTIVE_ITEM_ID                                      
    FROM TABLE(CAST(:B1 AS HRW_EC_ACTIVE_ITEM_ID_TABLE_T)) ) T WHERE HRW_EC_ACTIVE_ITEM.ACTIVE_ITEM_ID =                                       
    T.ACTIVE_ITEM_ID AND HRW_EC_ACTIVE_ITEM.SPROG_ID = SECURE_PROGRAMS.PROG_ID AND                                                             
    SECURE_PROGRAMS.STUDENT_RESOURCES_URL = :B2                                                                                                
    Plan hash value: 1418188916                                                                                                                
    | Id  | Operation                           | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |                          
    |   0 | SELECT STATEMENT                    |                           |       |       |  2136 (100)|          |                          
    |   1 |  SORT AGGREGATE                     |                           |     1 |    57 |            |          |                          
    |   2 |   HASH JOIN                         |                           |     3 |   171 |  2136   (1)| 00:00:26 |                          
    |   3 |    NESTED LOOPS                     |                           |  1103 | 60665 |  2111   (1)| 00:00:26 |                          
    |   4 |     INDEX RANGE SCAN                | SECURE_PROGRAMS_IDX_04    |    12 |   228 |     2   (0)| 00:00:01 |                          
    |   5 |     INDEX RANGE SCAN                | HRW_EC_ACTIVE_ITEM_IDX_03 | 10984 |   386K|   176   (1)| 00:00:03 |                          
    |   6 |    COLLECTION ITERATOR PICKLER FETCH|                           |       |       |            |          |                          
    Query Block Name / Object Alias (identified by operation id):                                                                              
       1 - SEL$62A3881B                                                                                                                        
       4 - SEL$62A3881B / SECURE_PROGRAMS@SEL$1                                                                                                
       5 - SEL$62A3881B / HRW_EC_ACTIVE_ITEM@SEL$1      Thanks,
    Brian

  • Strange Behavior with SQL/XML

    Our University have had for quite some time now a rather difficult situation with a very significant course handbook web site that creates HTML based on database XSL transformation of XML content generated with SQL/XML. The database is 10.2.0.2.0. The HTML is passed via a distributed database link to an Oracle Portal dynamic portlet for display. Some of the derived XML originates from XML Schema registered instance documents and some from relational storage.
    Let me explain. Occasionally after a period of operating (could be one week, sometimes even less) we will experience a problem whereby our derived XML content (just prior to PL/SQL database XSL transformation) will develop a parsing problem. Once this happens to one XSL transform of a course then subsequently it happens for every course viewed/transformed there-after.
    Recently I experienced the problem and then added the XMLNS argument to the extract function. That seemed to fix things and I thought I had it licked.
    Today we started to get the same problem again. The error reported was:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00242: invalid use of ampersand ('&') character (use &amp;)
    Error at line 1
    Now this might have been reasonable for one course. But every course reported the same problem there-after without fail. I managed to fix the issue but in a way that really doesn't seem to make sense. What I did was to alter the SQL/XML statement by adding in an extra XMLEMENT and then to recompile the function that returns an XMLTYPE based on the execution of the SQL statement. After compiling the function everything returned to normal.
    This doesn't seem to make sense.
    I am pretty desperate for help on this. I really don't know how to progress the solution. I don't get much joy from Oracle Support as our application covers too many high tech areas. This is really shaking confidence in our organization's use of Oracle technology.

    Hi Mark.
    We've isolated the problem a bit more now and there is a support SR (6089662.994). At this stage we are unable to reproduce - I am testing out an export though. The problem only occurs when a certain condition has been reached. Once that happens then extraneous characters are produced in the XMLTYPE feed returned by a function. We are not at all sure about how to make this condition occur. This doesn't just happen with one SQL/XML cursor - I've seen it happen with 3 different cursors. All are located in the same function that returns an XMLTYPE.
    We are convinced the problem lies with one or more SQL/XML cursors located in the same function. Once one of these cursors malfunctions it will produce XML that is not well formed OR on occasion has content omitted but is well formed (there often seem to be extraneous characters). When the XML content is not well formed then the parsing stage (dbms_xmlparser.parseclob(myparser, xml_clob)) of XSL transformation crashes. This error then propagates to the dynamic portlet in Oracle Portal thus removing the content on the page. This happens for every execution of the cursor while the condition manifests, the only difference between calls being bind variables.
    The interesting thing is that the error if left to itself will eventually stop. The cursor seems to right itself eventually. On the last occurrence, the problem commenced at 4.30am and went for 3.5 hrs and then seemed to right itself.

  • RSRT Performance Display SQL - Query has variables

    I have a query with mandatory variables on Year and Period, which are built into my RKF's.  I am trying to run the query via RSRT to see the SQL, but I keep getting error, variables must have values.....I tried creating variant in RSRT, but it goes to some odd screen.

    I do not get a prompt screen.  I go to RSRT,  Enter Query Name, next I Select Performance Info tab, then hit "Display SQL" button.  I get a message:  Specify a value for variable Posting Period (Single Value Entry, Mandatory)
    I never get a prompt.  I am on BI 7.

  • How Can I Make This Sql Query To Load Data Correctly (sql server)?

    Hi guys
    I have a datagridview where the third column is a custom column with all days
    of a month. It takes data with a query who distinct the column Improve.
    Here is the code :
    Private Sub fill_impro()
    dgImprove.Rows.Clear()
    Try
    Dim i As Integer = 0
    Dim query As String = "SELECT Improve,Price,Active,Idate FROM (SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Price ORDER BY Price) AS rn FROM tblImprove) tmp WHERE rn = 1"
    cmd = New SqlCommand(query, clsMSSQL.con)
    myDR = cmd.ExecuteReader
    If myDR.HasRows Then
    While myDR.Read
    dgImprove.Rows.Add()
    dgImprove.Rows(i).Cells(0).Value = myDR.GetDecimal(myDR.GetOrdinal("Price"))
    dgImprove.Rows(i).Cells(1).Value = myDR.GetString(myDR.GetOrdinal("Improve"))
    Dim myday As Integer = DatePart(DateInterval.Day, myDR.GetValue(myDR.GetOrdinal("Idate")))
    dgImprove.Rows(i).Cells(myday + 1).Value = myDR.GetInt32(myDR.GetOrdinal("Active"))
    i = i + 1
    End While
    End If
    myDR.Close()
    Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Critical, "Σφάλμα")
    End Try
    End Sub
    And here is the result :
    http://i60.tinypic.com/28gwf83.jpg
    The column Active value is 1.
    The problem is that column Active values are missing (red values in image).
    How can i fix that ?
    Thanks in advance

    try like this
    Dim Price As Decimal
    Dim improve As String = String.Empty
    While myDR.Read
    Dim myday As Integer = DatePart(DateInterval.Day, myDR.GetValue(myDR.GetOrdinal("Idate")))
    If Not (myDR.GetDecimal(myDR.GetOrdinal("Price")) = Price And myDR.GetString(myDR.GetOrdinal("Improve")) = improve) Then
    i += 1
    dgimprove.Rows.Add()
    dgimprove.Rows(i).Cells(0).Value = myDR.GetDecimal(myDR.GetOrdinal("Price"))
    dgimprove.Rows(i).Cells(1).Value = myDR.GetString(myDR.GetOrdinal("Improve"))
    Price = myDR.GetDecimal(myDR.GetOrdinal("Price"))
    improve = myDR.GetString(myDR.GetOrdinal("Improve"))
    End If
    dgimprove.Rows(i).Cells(myday + 1).Value = myDR.GetInt32(myDR.GetOrdinal("Active"))
    End While
    and change your sql statement to just
    SELECT Improve,Price,Active,Idate FROM tblImprove WHERE Active = 1

  • WRH$** tables, Need to know by which user SQL Query has been executed

    Hi,
    From the AWR data (WRH$) tables , I need to know how many sql code is using some specific indexes, I found that information by using the mentioned code. but I need to find out by which user this code has been executed ( not the PARSING_SCHEMA_NAME). Can someone please help me, how can I get that info?
    select a.operation,a.OBJECT_OWNER,a.OBJECT_NAME ,dbms_lob.substr(b.SQL_TEXT,4000,1) from WRH$_SQL_PLAN a,WRH$_SQLTEXT b
    where a.operation='INDEX' and a.SNAP_ID=b.SNAP_ID and a.SQL_ID=b.SQL_ID and a.OBJECT_NAME in (
    'I_CUSTORDER_STAT_CHG_DTM',
    'I_LINE_ITEM_STAT_CHG_DTM',
    'I_SHOPCART_MODIFIEDDTM',
    'I_VISITOR_CART_UPDATED_DTM',
    'R_ORDER_LOG_EVENT_DTM',
    'I_LI_STATUS_HISTORY_EVENT_DTM',
    'I_SHOPPING_CART_CREATEDDTM',
    'I_VISITOR_CART_CREATED_DTM',
    'I_LINE_ITEM_CREATED_DTM_FTM')

    872903 wrote:
    Hi,
    From the AWR data (WRH$) tables , I need to know how many sql code is using some specific indexes, I found that information by using the mentioned code. but I need to find out by which user this code has been executed ( not the PARSING_SCHEMA_NAME). Can someone please help me, how can I get that info?
    select a.operation,a.OBJECT_OWNER,a.OBJECT_NAME ,dbms_lob.substr(b.SQL_TEXT,4000,1) from WRH$_SQL_PLAN a,WRH$_SQLTEXT b
    where a.operation='INDEX' and a.SNAP_ID=b.SNAP_ID and a.SQL_ID=b.SQL_ID and a.OBJECT_NAME in (
    'I_CUSTORDER_STAT_CHG_DTM',
    'I_LINE_ITEM_STAT_CHG_DTM',
    'I_SHOPCART_MODIFIEDDTM',
    'I_VISITOR_CART_UPDATED_DTM',
    'R_ORDER_LOG_EVENT_DTM',
    'I_LI_STATUS_HISTORY_EVENT_DTM',
    'I_SHOPPING_CART_CREATEDDTM',
    'I_VISITOR_CART_CREATED_DTM',
    'I_LINE_ITEM_CREATED_DTM_FTM')consider enabling AUDIT SELECT FROM TABLE upon which INDEX is based.

  • Sql ddl replication strange behavior with create table

    Hello, I create the following table on my oracle DB server:
    CREATE TABLE test (a NUMBER(*,0) DEFAULT 0 NOT NULL,
    b DATE DEFAULT SYSDATE NOT NULL));
    ALTER TABLE test
    ADD CONSTRAINT pk_test PRIMARY KEY (a);
    when I deploy and sync, on the mobile I have the table well created, but the not null and default sysdate on the b column on are not set. It's null with no default values.
    Have anyone an idea ?
    Thank's for reply.

    We do not replicate not null or default values on Oracle Lite 5.0.2.x. This functionality will be available in the 10g release of Oracle Lite.
    - Junius

  • How Can I Make This Sql Query To Load Data Correctly (sql server 2014)?

    Hi guys
    I have a datagridview where the third column is a custom column with all days
    of a month. It takes data with a query who distinct the column Improve.
    SELECT Improve,Price,Active,Idate FROM (SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Improve ORDER BY Improve) AS rn FROM tblImprove) tmp WHERE rn = 1
    And here is the result :
    http://i60.tinypic.com/28gwf83.jpg
    The column Active value is 1.
    The problem is that column Active values are missing (red values in image).
    How can i fix that ?
    Thanks in advance
     

    Hi, 
    Maybe you can try below code, I have changed the order by of the row_number(). Therefore it will sort on the date, and you will get the first date icm with improve cell. If this is not what you are looking for, please explain what the output should be. 
    SELECT Improve,Price,Active,Idate
    FROM
    SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Improve ORDER BY ldate) AS rn
    FROM tblImprove
    ) tmp WHERE rn = 1
    Regards, 
    Reshma
    Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered

Maybe you are looking for