Help in Sys database query
Hi, How I can check the log data using the query after finding the databases and then join the table to see the log data if any.
How I can run query for all thing in one query. Thanks.
Select * from sys.databases where name like '%prt%'
BST_PRT
CST_PRT
DST_PRT
--I want to run the following query after finding the database using like command in sys.databases.
Select * from Khi_bst01.BST_PRT.dbo.log where date1>getdate()-4
union all
Select * from Khi_bst01.CST_PRT.dbo.log where date1>getdate()-4
union all
Select * from Khi_bst01.DST_PRT.dbo.log where date1>getdate()-4
Try the below:
SET @dSQL = @dSQL + 'SELECT
'+ @dbname
+' * FROM KHI_BST01.['+@dbname+'].dbo.log
WHERE date1 > DATEADD(DAY,-4,CURRENT_TIMESTAMP)'
Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
[Blog]
Similar Messages
-
Need help with multi database query.
Hello,
I am working on a query between multiple databases to be view on a web app. We have multiple web apps and we are integrating some functionality between them all into one page.
The data will be for a delegate someone sets for themselves (they can have more then one also). I need a way to pull the data view it as follows.
User, UserNumber, DelegateName, ForApp, ForApp, ForApp, ForApp, ForApp, ForApp
I have had no problem pulling the delegates themselves and which apps they are a delegate for, but not which person they are the delegate for.
SELECT DISTINCT
dbo.Employee.Position_Num AS Delegate_Position, dbo.Employee.Name AS [Delegate Name],
(CASE WHEN Hierarchy.dbo.Employee.Position_Num = CVI_Delegate.Delegate THEN 1 ELSE 0 END) AS For_CVI,
(CASE WHEN Hierarchy.dbo.Employee.Position_Num = Travel_Delegate.Delegate THEN 1 ELSE 0 END) AS For_Travel,
(CASE WHEN Hierarchy.dbo.Employee.Position_Num = Dept_Deposits_Delegate.Delegate THEN 1 ELSE 0 END) AS For_DeptDeposit,
dbo.OKCorral_Delegate.For_UserRoles AS For_OkCorralUR, dbo.OKCorral_Delegate.For_FiscalApprover AS For_OkCorralFA,
(CASE WHEN Hierarchy.dbo.Employee.Position_Num = Reqs_Delegate.Delegate THEN 1 ELSE 0 END) AS For_Reqs
FROM dbo.Employee LEFT OUTER JOIN
Reqs.dbo.Delegate AS Reqs_Delegate ON dbo.Employee.Position_Num = Reqs_Delegate.Position LEFT OUTER JOIN
DeptDeposits.dbo.Delegate AS Dept_Deposits_Delegate ON dbo.Employee.Position_Num = Dept_Deposits_Delegate.Position LEFT OUTER JOIN
CVI.dbo.Delegate AS CVI_Delegate ON dbo.Employee.Position_Num = CVI_Delegate.Position LEFT OUTER JOIN
dbo.OKCorral_Delegate ON dbo.Employee.Position_Num = dbo.OKCorral_Delegate.Position LEFT OUTER JOIN
Travel.dbo.Delegate AS Travel_Delegate ON dbo.Employee.Position_Num = Travel_Delegate.Position
This query works fine. The problem I run into is I have to use the same Employee table to get the EmployeeName and Number
Which will be used for both the person and the delegate. Any ideas will be a great help. It had been suggested I use a procedure to accomplish this, but I have no idea where to start that at. I also have tried a nested sbu-query but since
a person can have more then one delegate for an app, this through errors. Thanks.
George FieldsOk, here are the tables Travel Application Database/Delegate Table
INSERT INTO [Travel].[dbo].[Delegate]
([Position]
,[Delegate]
,[StartDate]
,[EndDate]
,[CreateDate]
,[EditDate])
VALUES
(<Position, char(6),>
,<Delegate, char(6),>
,<StartDate, datetime,>
,<EndDate, datetime,>
,<CreateDate, datetime,>
,<EditDate, datetime,>)
GO
Requistions Application /Table Delegates
INSERT INTO [Reqs].[dbo].[Delegate]
([Position]
,[Delegate]
,[StartDate]
,[EndDate]
,[CreateDate]
,[EditDate])
VALUES
(<Position, char(6),>
,<Delegate, char(6),>
,<StartDate, datetime,>
,<EndDate, datetime,>
,<CreateDate, datetime,>
,<EditDate, datetime,>)
GO
Heirarchy Database for Purchasing Application / Delegates Table
INSERT INTO [Hierarchy].[dbo].[OKCorral_Delegate]
([Dept_Campus]
,[For_DeptNum]
,[Position]
,[Delegate]
,[StartDate]
,[EndDate]
,[CreateDate]
,[EditDate]
,[For_FiscalApprover]
,[For_UserRoles])
VALUES
(<Dept_Campus, char(2),>
,<For_DeptNum, char(5),>
,<Position, char(6),>
,<Delegate, char(6),>
,<StartDate, datetime,>
,<EndDate, datetime,>
,<CreateDate, datetime,>
,<EditDate, datetime,>
,<For_FiscalApprover, bit,>
,<For_UserRoles, bit,>)
GO
Heirarchy Database / Employee Table
INSERT INTO [Hierarchy].[dbo].[Employee]
([Dept_Num]
,[Position_Num]
,[Email]
,[Name]
,[Campus]
,[CWID]
,[Student]
,[Employee]
,[OPID]
,[Gender]
,[Birth_Date])
VALUES
(<Dept_Num, char(5),>
,<Position_Num, char(6),>
,<Email, varchar(75),>
,<Name, varchar(150),>
,<Campus, char(2),>
,<CWID, varchar(16),>
,<Student, char(1),>
,<Employee, char(1),>
,<OPID, char(4),>
,<Gender, char(1),>
,<Birth_Date, char(8),>)
GO
The other two databases also have a delegate table similar to the ones above. As you can see all information about an employee is linked by their position number in the Employee Table.
The Position Number is used in the Position field and Delegate field of all the Delegate tables.
I am needing to pull an employee (actually all of them) List them and then show delegates for them by which applications the delegate holds permissions too. Which is the purpose of the delegate. So a delegate may only be a delegate for one application
or multiple which is why I am pulling from multiple databases.
George Fields -
Help about web database query _Thanks
Hi
I have a j2ee web application with oracle database.
I finish the function implementation by put all caculaton inside oracle query ( funciton (todayData - avg(historical data )) / std(historical data) and using group by and sub query .but performance is very slow about 3 minute whick is far from client's 10 second requirement.
My question is if I take raw data from database and do the caculation part in Java will it be faster. Is there some other way to speed up the process?(historical data is big)
Thanks for your time and helpMy question is if I take raw data from database and
do the caculation part in Java will it be faster. Is
there some other way to speed up the
process?(historical data is big)My initial reaction would be no, you should focus on opportunities to tune the SQL within Oracle. If you are talking about large volumes of data, pulling that data across a network or even through memory structures will only slow you down. Don't look for nits, look for changes that will have significant impact on performance, this could be creation of a new index, perhaps a bitmap index for performance, it could be simplifying the query by nesting queries rather then using sub-selects, based on the volume of data materialized views may be in order.
I really believe that focusing on Oracle will be the quickest solution for you to implement and has the best of chance of improving the performance to meet your users demands.
Having said that...
Given the scale of the problem, you may want to consider re-architecting the work that is being done by the query. This may include a hybrid solution that includes Oracle providing smaller subsets of data (lists) that can be quickly returned to the program and are in turn used as part of an ensuing query. This suggestion is different then pulling the raw database data into the application in that you are only pulling small amounts of data across the network. A hybrid solution, can be a very effective algorithm when combined with proper and efficient JDBC coding.
This is all pretty vague I know, but since I haven't seen your code or query it is difficult to be specific. -
Error Executing Database Query - Help!
I have a cfquery code that looks like this:
<CFQUERY DATASOURCE="mydatabase" USERNAME="myuser" PASSWORD="mypassword" NAME="codelist" CACHEDWITHIN="#CreateTimeSpan(0,1,0,0)#">
SELECT *
FROM systemcode
WHERE (LEN(TRIM(systemcode)) = 2 OR LEN(TRIM(systemcode)) = 4)
<CFSWITCH EXPRESSION="#CAT#">
<CFCASE VALUE="1">AND (MID(systemcode,1,2) BETWEEN '01' AND '05')</CFCASE>
<CFCASE VALUE="2">AND (MID(systemcode,1,2) BETWEEN '06' AND '15')</CFCASE>
<CFCASE VALUE="3">AND (MID(systemcode,1,2) BETWEEN '16' AND '24')</CFCASE>
<CFCASE VALUE="4">AND (MID(systemcode,1,2) BETWEEN '25' AND '27')</CFCASE>
<CFCASE VALUE="5">AND (MID(systemcode,1,2) BETWEEN '28' AND '38')</CFCASE>
<CFCASE VALUE="6">AND (MID(systemcode,1,2) BETWEEN '39' AND '40')</CFCASE>
<CFCASE VALUE="7">AND (MID(systemcode,1,2) BETWEEN '41' AND '43')</CFCASE>
<CFCASE VALUE="8">AND (MID(systemcode,1,2) BETWEEN '44' AND '49')</CFCASE>
<CFCASE VALUE="9">AND (MID(systemcode,1,2) BETWEEN '50' AND '63')</CFCASE>
<CFCASE VALUE="10">AND (MID(systemcode,1,2) BETWEEN '64' AND '67')</CFCASE>
<CFCASE VALUE="11">AND (MID(systemcode,1,2) BETWEEN '68' AND '71')</CFCASE>
<CFCASE VALUE="12">AND (MID(systemcode,1,2) BETWEEN '72' AND '83')</CFCASE>
<CFCASE VALUE="13">AND (MID(systemcode,1,2) BETWEEN '84' AND '85')</CFCASE>
<CFCASE VALUE="14">AND (MID(systemcode,1,2) BETWEEN '86' AND '89')</CFCASE>
<CFCASE VALUE="15">AND (MID(systemcode,1,2) BETWEEN '90' AND '97')</CFCASE>
<CFCASE VALUE="16">AND (MID(systemcode,1,2) BETWEEN '98' AND '99')</CFCASE>
<CFDEFAULTCASE><CFLOCATION URL="somewhere.htm"></CFDEFAULTCASE>
</CFSWITCH>
ORDER BY systemcode
</CFQUERY>
This works perfectly in CF 5. However, when running in CF 8 I am getting the error message:
Error Executing Database Query.FUNCTION mydatabase.LEN does not exist The specific sequence of files included or processed is: /home/httpd/vhosts/somedomain.com/httpdocs/reference/systemcode.cfm, line: 24
(that refers to the above cfquery)
"mydatabase" is the name of the database and LEN is a function. It's checking for the length of systemcode to be 2 or 4, if they are then check if the value of #CAT# is 1 and that the first 2 characters is between 01 and 05 then select the row. I don't know why it works with CF5 but not CF8? It's driving me nuts. Any help is appreciated.I just don't see why
all of a sudden it doesn't work with CF8 and MySQL,
If you changed databases, that is the source of the problem, not upgrading CF. MySQL will not understand MS Access specific functions and vice versa. Do not expect queries written for one database type to automatically work with another. While there are sql standards, every database is different. It is quite common for database vendors to have totally different function names, data types and even syntax. You will need to throrougly review your database queries and convert any Access specific syntax, data types, etcetera to the MySQL equivalents.
Are there MySQL equivalent for these two functions (TRIM and
LEN)?
Yes. See the string functions section in the online mySQL docs.
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
I don't konw there was a TRIM and LEN in MS Access
database. I guess I was mixing them.
Yes. It is a little confusing because both CF and MS Access have those functions. In this specific case you were using the Access functions, not CF.
http://www.techonthenet.com/access/functions/index_alpha.php
>> Yes, I did put a
CFLOCATION inside the cfquery. Never encounter that
scenario so I didn't know if it works.
Well if you are using the code, it should be something you have tested. So you know how it behaves. But CFLOCATION really does not belong inside a database query.
` -
Error Executing Database Query. (Please help)
I can't get this query to work properly. I have gone over it so many times.. I can't count, I don't get why it's throwing an error. Here is my code, and followed by the error:
My update query:
<cfquery name="UpdateDetails" datasource="#APPLICATION.dataSource#">
UPDATE books234
SET
books234.title=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.title#">,
books234.info=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.info#">,
books234.statement=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.statement#">,
<cfif fileuploaded is true>
books234.MYFile=<cfqueryparam cfsqltype="cf_sql_varchar" value="#uploadedfile#">,
</cfif>
books234.links=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.links#">,
books234.ordNum=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.ordNum#">
WHERE books234.ID = <cfqueryparam value="#form.ID#" cfsqlType="CF_SQL_INTEGER">
</cfquery>
<cflocation url="bookView.cfm?ID=#Form.ID#" addtoken="no">
Here is my error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver]Invalid precision value
The error occurred in C:\websites\209689jh6\slideAction.cfm: line 455
Called from C:\websites\209689jh6\admin\cms\slideAction.cfm: line 442
Called from C:\websites\209689jh6\admin\cms\slideAction.cfm: line 390
Called from C:\websites\209689jh6\admin\cms\slideAction.cfm: line 1
Called from C:\websites\209689jh6\admin\cms\slideAction.cfm: line 455
Called from C:\websites\209689jh6\admin\cms\slideAction.cfm: line 442
Called from C:\websites\209689jh6\admin\cms\slideAction.cfm: line 390
Called from C:\websites\209689jh6\admin\cms\slideAction.cfm: line 1
453 : books234.links=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.links#">,
454 : books234.ordNum=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.ordNum#">
455 : WHERE books234.ID = <cfqueryparam value="#form.ID#" cfsqlType="CF_SQL_INTEGER">
456 : </cfquery>
457 : <cflocation url="bookView.cfm?ID=#Form.ID#" addtoken="no">
Can anyone see what I did wrong here? It's not like it's a sophisticated query. I write these all the time.
Thank you.Does it work without using cfqueryparam in the WHERE statement? Are you sure the type CF_SQL_INTEGER is correct? Is the value of form.ID really an integer?
Cheers -
Hi all,
Help me here when i try am unable to get a data,Can some one help me with a query to get.
If it cant be done can i know why..
select * from Sys.databases
where owner_sid='0x01'
What am trying is to get a login
names from syslogin
table with respect to Sid.
Select a.name,b.name,a.owner_sid from Sys.databases a
Join Syslogins b
on a.owner_sid = b.sid
where owner_sid like '0x01'
Thanks all in Advance.....Below are a couple of examples of how to accomplish the task. Note that SID is varbinary so the literal should not be enclosed in quotes.
SELECT
a.name AS DatabaseName
,b.name AS OwnerName
,a.owner_sid AS OwnerSID
FROM sys.databases a
JOIN sys.server_principals b ON
a.owner_sid = b.sid
WHERE owner_sid = 0x01;
SELECT
a.name AS DatabaseName
,SUSER_SNAME(owner_sid) AS OwnerName
,a.owner_sid AS OwnerSID
FROM sys.databases a
WHERE a.owner_sid = 0x01;
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
Hi all,
how to find physical query from report here m checking like Administrator->manage session--> report-->view log
+++Administrator:3220000:3220011:----2011/01/03 02:51:43
-------------------- SQL Request:
+++Administrator:3220000:3220011:----2011/01/03 02:51:43
-------------------- General Query Info:
Repository: Star, Subject Area: AAA, Presentation: AAA
+++Administrator:3220000:3220011:----2011/01/03 02:51:43
-------------------- Cache Hit on query:
Matching Query: Created by: Administrator
+++Administrator:3220000:3220011:----2011/01/03 02:51:43
-------------------- Query Status: Successful Completion
+++Administrator:3220000:3220011:----2011/01/03 02:51:43
-------------------- Physical Query Summary Stats: Number of physical queries 1, Cumulative time 0, DB-connect time 0 (seconds)
+++Administrator:3220000:3220011:----2011/01/03 02:51:43
-------------------- Rows returned to Client 6
+++Administrator:3220000:3220011:----2011/01/03 02:51:43
-------------------- Logical Query Summary Stats: Elapsed time 0, Response time 0, Compilation time 0 (seconds)
but here m not able to find database query..how to find that query plz help
Edited by: Sonal on Jan 3, 2011 5:29 AM
Edited by: Sonal on Jan 3, 2011 5:30 AM
Edited by: Sonal on Jan 3, 2011 5:30 AMHi,
as Daan said, set the variable in Advanced tab but not on loglevel..
because, our problem is to bypass the bi-server cache.
Do this:
1. Go to Advanced tab.
2. In Prefix field(scroll down to see this field) , enter this:
SET DISABLE_CACHE_HIT = 1;
Note: Make sure that you're ended up above statement with semicolon and do not click on Set SQL option...
3. Save report, then run it..
4. After you see the query, i recommend you to take take out that prefix tag then save it again.. -
Generate an xml file from Database query results
Hi, can anyone help me out with this problem I'm having. What are the steps in creating an xml file directly from the results of a database query. I currently have a very simply process that queries a database via a partner link. The query returns the data but it's from this point that I am stuck. I need to create an xml file with the data along with the xml tags. I've looked at dozens of tutorials with no luck.
I would greatly appreciate help with this.
bpel rookieShould be quite simple.
Create another partnerlink, configure it to use the file adapter, and write to an XML file. In this case you need to create an XML Schema (.xsd) of the file you want to create.
Before you write to the file, either add assign steps to copy individual attributes or use a transform activity to convert from the database format to the file (xml) format. -
Dear All,
My database is 11gR2 on Linux.
I am struck in writing a difficult query, need help from your guys.
I have a table, an application is controlling the columns of this table. Columns are added by the application.
This is the structure of the table:
create table imran_test(
2 username varchar2(100),
3 layer1 number(1),
4 layer2 number(2),
5 layer3 number(2));
-- where layer1, layer2, layer3.... are increased up to layer 22 and could be increased more...
Now each username will have 1 in any one of the layer, and all other layers will have 0
Like if I consider the above table this could be the sample data:
imran 1 0 0
hafeez 0 1 0
james 0 0 1
Now the result my query should return is:
select username, <column name where value is 1> and value of it, as per sample data, this should be return by the query:
imran layer1 1
hafeez layer2 1
james layer 3 1
Note: Please remember the columns are not fixed, they are added/altered by application.
Regards,
ImranThe table design is incorrect as it is not in 3NF and has a repeating group
You should correct the 'design' first or turn the layer... columns in a VARRAY.
Also my feeling is you should change your subject line 'Help in writing a query!' in 'Write my query' as that is what you actually ask, and leave out the exclamation mark.
Basically you dump everything in this forum, and being a bit less demanding might suit you better.
Also you still act rude by not marking your questions as answered.
Change that
Sybrand Bakker
Senior Oracle DBA
Edited by: sybrand_b on 1-apr-2012 12:09 -
How to extract the Physical Query(database Query)
Hi ,
How to extract the Physical Query(database Query) from obiee which was fired in obiee
Regards
RangaHi Ranganath,
Have a look the following links.
Setting Logging level:
http://gerardnico.com/wiki/dat/obiee/loglevel
How to see physical query:
http://gerardnico.com/wiki/dat/obiee/manage_session_log
If you are new to OBIEE, spend some hours on the following blog to learn from basics to advanced level.
http://gerardnico.com/wiki/
http://obiee101.blogspot.com/
http://www.rittmanmead.com/blog/
Hope it helps you.
Regards,
Kalyan Chukkapalli
http://123obi.com -
XPATH Database Query Syntax in an Assign
Trying to get an XPATH Database query to work by assigning the Input variable value in a simple BPEL Process to my query condition. I keep getting invalid XPATH errors. I cannot seem to figure out how get write it out.
Here is what I have:
<from expression="orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')"/>
Here is my error:
Error(30): [Error ORABPEL-10039]: invalid xpath expression [Description]: in line 30 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\BPELws\ReadDB\ReadDB.bpel", xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" specified in <from> is not valid, because XPath query syntax error. Syntax error while parsing xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')", at position "80" the exception is Expected: ). Please verify the xpath query "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" which is defined in BPEL process. . [Potential fix]: Please make sure the expression is valid.
Any help?
Thanks!!!Ok. I have figured out how to place the condition (variable value) inside a concatentated string. So my final result is the actual XPATH Query-Database statement. But the problem is it is being returned as a String. How can I turn that final string into the XPATH expression I need? I suspect another <COPY> block could pull this off but I am not sure how to do it.
Here is my code:
<process name="QueryBuild" targetNamespace="http://xmlns.oracle.com/QueryBuild" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:client="http://xmlns.oracle.com/QueryBuild" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
<partnerLinks>
<partnerLink name="client" partnerLinkType="client:QueryBuild" myRole="QueryBuildProvider"/>
</partnerLinks>
<variables>
<variable name="inputVariable" messageType="client:QueryBuildRequestMessage"/>
<variable name="outputVariable" messageType="client:QueryBuildResponseMessage"/>
<variable name="QueryText" type="ns1:string"/>
</variables>
<sequence name="main">
<receive name="receiveInput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="inputVariable" createInstance="yes"/><!-- Generate reply to synchronous request -->
<assign name="Assign_1">
<copy>
<from expression="concat("orcl:query-database('select ename from emp where empno = ", bpws:getVariableData('inputVariable','payload','/client:QueryBuildProcessRequest/client:input'), ",false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL)'")"/>
<to variable="QueryText"/>
</copy>
<copy>
<from variable="QueryText"/>
<to variable="outputVariable" part="payload" query="/client:QueryBuildProcessResponse/client:result"/>
</copy>
</assign>
<reply name="replyOutput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="outputVariable"/>
</sequence>
</process> -
Plz help in optimizing the query
I have a query which is written to cater to the scenario that the entered start and end date do not overlap with the start and end date already present in the database records. Can someone help in optimizing this query. all inclusion and exclusion scenario's have to be taken care of.
the query is as follows:
SELECT COUNT(*) FROM CLAS WHERE TRIM(UPPER(CLAS_CDE)) =UPPER('timecheck') AND TRIM(UPPER(CLAS_TYPE_CDE))=UPPER('TEST_3')
AND TRIM(UPPER(LANG_CDE))=UPPER('en')
AND (
(END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
OR
(START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
OR (
(START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
AND
(END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
OR(('09/13/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
AND ('09/15/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
);I format your code in different way:
SELECT COUNT(*)
FROM CLAS
WHERE TRIM(UPPER(CLAS_CDE)) = UPPER('timecheck')
AND TRIM(UPPER(CLAS_TYPE_CDE))=UPPER('TEST_3')
AND TRIM(UPPER(LANG_CDE))=UPPER('en')
AND (
(END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
OR
(START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
OR (
(START_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
AND
(END_DT BETWEEN TO_DATE('09/13/2007','MM/DD/YYYY') AND TO_DATE('09/15/2007','MM/DD/YYYY'))
OR (
('09/13/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
AND
('09/15/2007' BETWEEN TO_CHAR(START_DT,'MM/DD/YYYY') AND TO_CHAR(END_DT,'MM/DD/YYYY'))
);First thought that cross my mind it to check if changing this:
UPPER('timecheck') to simple:
'TIMECHECK' and do the same with other expressions with UPPER function.
Peter D. -
Help to rewrite the query --performance issue
Hi ,
Please help to rewrite the query since it's performance is not good.Especially second inline query(CASE statements are therein select caluse ..)is taking more cost.
Database Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
SELECT *
FROM
(SELECT q.*,
COUNT(*) OVER() AS record_count,
ROWNUM AS row_num
FROM
(SELECT ExName.examiner_code,
examiner_name,
:v_year,
:v_month,
count_fb,
NVL(count_entered_fb, 0) count_entered_fb,
NVL(count_sent_fb, 0) count_sent_fb,
NVL(count_edited_fb, 0) count_edited_fb,
NVL(count_complete_fb, 0) count_complete_fb,
NVL(count_withibcardiff_fb, 0) count_withibcardiff_fb
FROM
(SELECT examiner_code,
COUNT(*) AS count_fb
FROM
(SELECT
examiner_code,
paper_code,
assessment_school
FROM
( SELECT DISTINCT ce.examiner_code,
ce.paper_code,
ce.assessment_school
FROM
(SELECT
DISTINCT assessment_school,
paper_code,
examiner_code
FROM candidate_examiner_allocation cea
WHERE cea.element = 'Moderation of IA'
AND cea.year = :v_year
AND cea.month = :v_month
) ce,
subject_group sg,
subject_component sc
WHERE (:v_padded_examiner_code IS NULL
OR ce.examiner_code = :v_padded_examiner_code)
AND (:v_subject_group IS NULL
OR sg.group_number = :v_subject_group)
AND sg.year = :v_year
AND sg.month = :v_month
AND sc.year = :v_year
AND sc.month = :v_month
AND sc.paper_code = ce.paper_code
AND sc.subject = sg.subject
AND sc.lvl = sg.lvl
AND (:v_subject IS NULL
OR sc.subject = :v_subject)
AND (:v_lvl IS NULL
OR sc.lvl = :v_lvl)
) ea
GROUP BY examiner_code
) ExName,
(SELECT examiner_code,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'ENTERED'
THEN 1
ELSE NULL
END) AS count_entered_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'SENT'
THEN 1
ELSE NULL
END) AS count_sent_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'EDITED'
THEN 1
ELSE NULL
END) AS count_edited_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'COMPLETE'
THEN 1
ELSE NULL
END) AS count_complete_fb,
COUNT(
CASE
WHEN UPPER(wfi.status) = 'WITH IBCARDIFF'
THEN 1
ELSE NULL
END) AS count_withibcardiff_fb
FROM ia_instances ia1,
workflow_instance wfi
WHERE wfi.instance_id = ia1.workflow_instance_id
AND ia1.year = :v_year
AND ia1.month = :v_month
GROUP BY ia1.year,
ia1.month,
examiner_code
) iaF,
(SELECT person_code,
title
|| ' '
|| firstname
|| ' '
|| lastname AS examiner_name
FROM person
WHERE :v_examiner_name IS NULL
OR UPPER(title
|| ' '
|| firstname
|| ' '
|| lastname) LIKE :v_search_examiner_name
) P
WHERE ExName.examiner_code = iaF.examiner_code (+)
AND ExName.examiner_code = p.person_code
ORDER BY ExName.examiner_code
) q
) rc
WHERE row_num >= :v_start_row
AND row_num <= (:v_start_row+(:v_max_row-1));explain plan
line 1: SQLPLUS Command Skipped: set linesize 130
line 2: SQLPLUS Command Skipped: set pagesize 0
PLAN_TABLE_OUTPUT
Plan hash value: 1581970599
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 276 | | 2187 (6)| 00:00:34 |
|* 1 | FILTER | | | | | | |
|* 2 | VIEW | | 1 | 276 | | 2187 (6)| 00:00:34 |
| 3 | WINDOW BUFFER | | 1 | 250 | | 2187 (6)| 00:00:34 |
| 4 | COUNT | | | | | | |
| 5 | VIEW | | 1 | 250 | | 2187 (6)| 00:00:34 |
| 6 | SORT ORDER BY | | 1 | 119 | | 2187 (6)| 00:00:34 |
| 7 | NESTED LOOPS | | 1 | 119 | | 2186 (6)| 00:00:34 |
|* 8 | HASH JOIN OUTER | | 1 | 92 | | 2185 (6)| 00:00:34 |
| 9 | VIEW | | 1 | 20 | | 51 (4)| 00:00:01 |
| 10 | SORT GROUP BY | | 1 | 7 | | 51 (4)| 00:00:01 |
| 11 | VIEW | | 1 | 7 | | 51 (4)| 00:00:01 |
| 12 | SORT UNIQUE | | 1 | 127 | | 51 (4)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 127 | | 50 (2)| 00:00:01 |
|* 14 | HASH JOIN | | 1 | 68 | | 44 (3)| 00:00:01 |
|* 15 | TABLE ACCESS BY INDEX ROWID| SUBJECT_COMPONENT | 13 | 520 | | 40 (0)| 00:00:01 |
|* 16 | INDEX RANGE SCAN | SUBJECT_COMPONENT_ASSESS_TYPE | 1059 | | | 9 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | SUBJECT_GROUP_PK | 41 | 1148 | | 3 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | CEA_AUTOMATIC_ALLOCATION_STATS | 5 | 295 | | 6 (0)| 00:00:01 |
| 19 | VIEW | | 679 | 48888 | | 2133 (6)| 00:00:33 |
| 20 | SORT GROUP BY | | 679 | 25123 | | 2133 (6)| 00:00:33 |
|* 21 | HASH JOIN | | 52408 | 1893K| 1744K| 2126 (6)| 00:00:33 |
| 22 | TABLE ACCESS BY INDEX ROWID | IA_INSTANCES | 52408 | 1125K| | 688 (1)| 00:00:11 |
|* 23 | INDEX RANGE SCAN | IND_IA_INSTANCES | 49077 | | | 137 (2)| 00:00:03 |
| 24 | TABLE ACCESS FULL | WORKFLOW_INSTANCE | 1075K| 15M| | 960 (7)| 00:00:15 |
|* 25 | TABLE ACCESS BY INDEX ROWID | PERSON | 1 | 27 | | 1 (0)| 00:00:01 |
|* 26 | INDEX UNIQUE SCAN | PERSON_PK | 1 | | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(TO_NUMBER(:V_START_ROW)<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1))
2 - filter("ROW_NUM">=TO_NUMBER(:V_START_ROW) AND "ROW_NUM"<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1))
8 - access("EXNAME"."EXAMINER_CODE"="IAF"."EXAMINER_CODE"(+))
14 - access("SC"."SUBJECT"="SG"."SUBJECT" AND "SC"."LVL"="SG"."LVL")
15 - filter((:V_SUBJECT IS NULL OR "SC"."SUBJECT"=:V_SUBJECT) AND ("SC"."LVL"=:V_LVL OR :V_LVL IS NULL))
16 - access("SC"."YEAR"=TO_NUMBER(:V_YEAR) AND "SC"."MONTH"=:V_MONTH)
17 - access("SG"."YEAR"=TO_NUMBER(:V_YEAR) AND "SG"."MONTH"=:V_MONTH)
filter(:V_SUBJECT_GROUP IS NULL OR "SG"."GROUP_NUMBER"=TO_NUMBER(:V_SUBJECT_GROUP))
18 - access("CEA"."YEAR"=TO_NUMBER(:V_YEAR) AND "CEA"."MONTH"=:V_MONTH AND "SC"."PAPER_CODE"="PAPER_CODE" AND
"CEA"."ELEMENT"='Moderation of IA')
filter("CEA"."ELEMENT"='Moderation of IA' AND (:V_PADDED_EXAMINER_CODE IS NULL OR
"EXAMINER_CODE"=:V_PADDED_EXAMINER_CODE))
21 - access("WFI"."INSTANCE_ID"="IA1"."WORKFLOW_INSTANCE_ID")
23 - access("IA1"."YEAR"=TO_NUMBER(:V_YEAR) AND "IA1"."MONTH"=:V_MONTH)
25 - filter(:V_EXAMINER_NAME IS NULL OR UPPER("TITLE"||' '||"FIRSTNAME"||' '||"LASTNAME") LIKE :V_SEARCH_EXAMINER_NAME)
26 - access("EXNAME"."EXAMINER_CODE"="PERSON_CODE")
53 rows selectedHi,
please find the below rigjt explan paln.
PLAN_TABLE_OUTPUT
SQL_ID 2ct41vyyzqyh7, child number 0
SELECT * FROM (SELECT q.*, COUNT(*) OVER() AS record_count, ROWNUM AS row_num FROM (SELECT
ExName.examiner_code, examiner_name, :v_year, :v_month, count_fb, NVL(count_entered_fb,
0) count_entered_fb, NVL(count_sent_fb, 0) count_sent_fb, NVL(count_edited_fb, 0) count_edited_fb,
NVL(count_complete_fb, 0) count_complete_fb, NVL(count_withibcardiff_fb, 0) count_withibcardiff_fb FROM
(SELECT examiner_code, COUNT(*) AS count_fb FROM (SELECT
examiner_code, paper_code, assessment_school FROM ( SELECT DISTINCT
ce.examiner_code, ce.paper_code, ce.assessment_school FROM (SELECT
DISTINCT assessment_school,
paper_code, examiner
Plan hash value: 651311258
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | | 2785 (100)| |
|* 1 | FILTER | | | | | | |
|* 2 | VIEW | | 4 | 1104 | | 2785 (7)| 00:00:43 |
| 3 | WINDOW BUFFER | | 4 | 1000 | | 2785 (7)| 00:00:43 |
| 4 | COUNT | | | | | | |
| 5 | VIEW | | 4 | 1000 | | 2785 (7)| 00:00:43 |
| 6 | NESTED LOOPS | | 4 | 476 | | 2785 (7)| 00:00:43 |
| 7 | MERGE JOIN OUTER | | 4 | 368 | | 2781 (7)| 00:00:43 |
| 8 | VIEW | | 4 | 80 | | 72 (3)| 00:00:02 |
| 9 | SORT GROUP BY | | 4 | 28 | | 72 (3)| 00:00:02 |
| 10 | VIEW | | 4 | 28 | | 72 (3)| 00:00:02 |
| 11 | SORT UNIQUE | | 4 | 508 | | 72 (3)| 00:00:02 |
| 12 | NESTED LOOPS | | 4 | 508 | | 71 (2)| 00:00:02 |
|* 13 | HASH JOIN | | 1 | 68 | | 44 (3)| 00:00:01 |
|* 14 | TABLE ACCESS BY INDEX ROWID| SUBJECT_COMPONENT | 13 | 520 | | 40 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | SUBJECT_COMPONENT_ASSESS_TYPE | 1059 | | | 9 (0)| 00:00:01 |
|* 16 | INDEX RANGE SCAN | SUBJECT_GROUP_PK | 41 | 1148 | | 3 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | CEA_AUTOMATIC_ALLOCATION_STATS | 30 | 1770 | | 27 (0)| 00:00:01 |
|* 18 | SORT JOIN | | 576 | 41472 | | 2709 (7)| 00:00:42 |
| 19 | VIEW | | 576 | 41472 | | 2708 (7)| 00:00:42 |
| 20 | SORT GROUP BY | | 576 | 21312 | | 2708 (7)| 00:00:42 |
|* 21 | HASH JOIN | | 52408 | 1893K| 1744K| 2701 (7)| 00:00:41 |
|* 22 | TABLE ACCESS FULL | IA_INSTANCES | 52408 | 1125K| | 1263 (6)| 00:00:20 |
| 23 | TABLE ACCESS FULL | WORKFLOW_INSTANCE | 1075K| 15M| | 960 (7)| 00:00:15 |
|* 24 | TABLE ACCESS BY INDEX ROWID | PERSON | 1 | 27 | | 1 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | PERSON_PK | 1 | | | 0 (0)| |
Predicate Information (identified by operation id):
1 - filter(TO_NUMBER(:V_START_ROW)<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1))
2 - filter(("ROW_NUM">=TO_NUMBER(:V_START_ROW) AND "ROW_NUM"<=TO_NUMBER(:V_START_ROW)+(TO_NUMBER(:V_MAX_ROW)-1)))
13 - access("SC"."SUBJECT"="SG"."SUBJECT" AND "SC"."LVL"="SG"."LVL")
14 - filter(((:V_SUBJECT IS NULL OR "SC"."SUBJECT"=:V_SUBJECT) AND ("SC"."LVL"=:V_LVL OR :V_LVL IS NULL)))
15 - access("SC"."YEAR"=TO_NUMBER(:V_YEAR) AND "SC"."MONTH"=:V_MONTH)
16 - access("SG"."YEAR"=TO_NUMBER(:V_YEAR) AND "SG"."MONTH"=:V_MONTH)
filter((:V_SUBJECT_GROUP IS NULL OR "SG"."GROUP_NUMBER"=TO_NUMBER(:V_SUBJECT_GROUP)))
17 - access("CEA"."YEAR"=TO_NUMBER(:V_YEAR) AND "CEA"."MONTH"=:V_MONTH AND "SC"."PAPER_CODE"="PAPER_CODE" AND
"CEA"."ELEMENT"='Moderation of IA')
filter(("CEA"."ELEMENT"='Moderation of IA' AND (:V_PADDED_EXAMINER_CODE IS NULL OR
"EXAMINER_CODE"=:V_PADDED_EXAMINER_CODE)))
18 - access("EXNAME"."EXAMINER_CODE"="IAF"."EXAMINER_CODE")
filter("EXNAME"."EXAMINER_CODE"="IAF"."EXAMINER_CODE")
21 - access("WFI"."INSTANCE_ID"="IA1"."WORKFLOW_INSTANCE_ID")
22 - filter(("IA1"."MONTH"=:V_MONTH AND "IA1"."YEAR"=TO_NUMBER(:V_YEAR)))
24 - filter((:V_EXAMINER_NAME IS NULL OR UPPER("TITLE"||' '||"FIRSTNAME"||' '||"LASTNAME") LIKE :V_SEARCH_EXAMINER_NAME))
25 - access("EXNAME"."EXAMINER_CODE"="PERSON_CODE")
66 rows selected -
My coldfusion service crashes intermitantly and when I check
the application logs the error that I see for the time frame is the
one below. Does anyone know where I might begain to solve this?
Thanks!
Error Executing Database
Query.coldfusion.sql.DatabaseConnectionException: Timed out trying
to establish connection The specific sequence of files included or
processed is: E:\wwwroot\lifeworks\default.cfmI'm no expert, but thought I would try to be helpful.
I was getting this same error on a regular basis.
The short term fix was to restart the ODBC server service.
The long term fix was twofold:
1. I recreated the ODBC connection in ColdFusion
Administrator to use the system connection (I was using the SA and
PW for login).
2. I created a second user ODBC connection as well as the
system one under ODBC in Windows Server 2003.
I haven't had the problem since.
I also read a pretty good set of "stuff" to try from the help
area:
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_17277
Hope this helps. -
Hi Experts,
An out of box Question, but i expect that someone might have faced this problem and has been successful in searching the way out of it.
Am getting a message on running the following symmetric command to take archive log backup.
symioctl archive log
On issuing the above command , it returns me this message :
"Database query support is not installed"
Can anyone help me? How can i install database query support ?
Thanks in advance,,,,
MBThis is the technique that I use to count rows:
Quick trick that I use is
1. make sure that your Statement is type_scroll_insensitive:
connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);2. move your cursor to the last row(after executing your query)
resultset.last();3. get the row number:
int numberOfRows = resultset.getRow(); /*returns the number of rows*/4. set the cursor back to the beginning:
resultset.beforeFirst();5. ready to process the rows as usual.
This technique has a drawback though:
a scrollable resultset has less performance than non-scrollable
hope this might help,
Jamie
Maybe you are looking for
-
Set value in tabular form field with dynamic action
Hi Guys, I have a dummy field in a tabular form which I am trying to use to populate another field in the tabular form when it is changed. In the tabular form I have an ITEM_ID field. Each item_id has an ITEM_NAME which is the dummy field as it is no
-
Customer Balance carried forward
Hi, We have customer whose balance is 29000 as on 31.12.2006. The carry forward is done through F.07. But the balance as on 1.1.2007 is 10000. I dont know what has gone wrong exactly. I tried doing F.07 transaction again on Test run Mode. But know it
-
My iPod mini will not turn on and when i try to charge it, it just freezes and shows an apple. what can i do
-
Why does HV not have pre-programmed fields for extremely common blood tests such as the CBC, the Comprehensive Metabolic Profile, and Urinalysis like it does for Blood Glucose and Cholesterol measurements? It's extremely cumbersome to enter these va
-
ADF war file deploy as portlet
I have also posted this on "Portal - General" but I will update both with any solutions that come in, hopefully soon. I have successfully deployed the sample portlet files contained in portlet-container.zip. I also then tested that it was possible to