Complex query crashing database!
Hi
Our 10g database runs on Windows 2003 (with 32 GB RAM on server).
Whenever a user is running a particular complex query, the database just crashes suddenly.
In fact, it doesn't write anything in alert log file for any problem.
The user starts the query, it runs for sometime, then suddenly database crashes!
Only way to work there after is to restart the database.
Although I asked the user to not to run that query again but it is generated by some application which may generate similar query again!
So, how I can prevent database from crashing again?
Will creating a resource profile to allocate finite resource help? Problem is since database crashes so suddenly, I can't find any info from log files!
Thanx
The database instance crashes. We have to start the ORACLE.EXE again to up the database.
Here is last few lines of the alert.log
Fri Feb 05 11:14:59 2010
Setting recovery target incarnation to 1
Fri Feb 05 11:14:59 2010
Successful mount of redo thread 1, with mount id 1911309359
Fri Feb 05 11:14:59 2010
Database mounted in Exclusive Mode
Completed: alter database mount exclusive
Fri Feb 05 11:14:59 2010
alter database open
Fri Feb 05 11:15:00 2010
Beginning crash recovery of 1 threads
parallel recovery started with 7 processes
Fri Feb 05 11:15:00 2010
Started redo scan
Fri Feb 05 11:15:00 2010
Completed redo scan
3886 redo blocks read, 276 data blocks need recovery
Fri Feb 05 11:15:00 2010
Started redo application at
Thread 1: logseq 179837, block 3
Fri Feb 05 11:15:00 2010
Recovery of Online Redo Log: Thread 1 Group 6 Seq 179837 Reading mem 0
Mem# 0 errs 0: F:\DB LOG FILES\ORADATA\REDO06.LOG
Mem# 1 errs 0: F:\DB LOG FILES MULTIPLEXED\ORADATA\REDO06.LOG
Fri Feb 05 11:15:00 2010
Completed redo application
Fri Feb 05 11:15:00 2010
Completed crash recovery at
Thread 1: logseq 179837, block 3889, scn 10584777673
276 data blocks read, 276 data blocks written, 3886 redo blocks read
Fri Feb 05 11:15:01 2010
LGWR: STARTING ARCH PROCESSES
ARC0 started with pid=21, OS id=5752
Fri Feb 05 11:15:01 2010
ARC0: Archival started
ARC1: Archival started
ARC1 started with pid=22, OS id=4548
Fri Feb 05 11:15:02 2010
LGWR: STARTING ARCH PROCESSES COMPLETE
Thread 1 advanced to log sequence 179838
Thread 1 opened at log sequence 179838
Current log# 7 seq# 179838 mem# 0: F:\DB LOG FILES\ORADATA\REDO07.LOG
Current log# 7 seq# 179838 mem# 1: F:\DB LOG FILES MULTIPLEXED\ORADATA\REDO07.LOG
Successful open of redo thread 1
Fri Feb 05 11:15:02 2010
ARC1: STARTING ARCH PROCESSES
Fri Feb 05 11:15:02 2010
ARC0: Becoming the 'no FAL' ARCH
ARC0: Becoming the 'no SRL' ARCH
Fri Feb 05 11:15:02 2010
SMON: enabling cache recovery
Fri Feb 05 11:15:02 2010
ARC2: Archival started
ARC1: STARTING ARCH PROCESSES COMPLETE
ARC2 started with pid=23, OS id=6120
Fri Feb 05 11:15:02 2010
Successfully onlined Undo Tablespace 1.
Fri Feb 05 11:15:02 2010
SMON: enabling tx recovery
Fri Feb 05 11:15:02 2010
Database Characterset is WE8MSWIN1252
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=25, OS id=5312
Fri Feb 05 11:15:03 2010
Completed: alter database open
Fri Feb 05 11:15:03 2010
ARC1: Becoming the heartbeat ARCH
Fri Feb 05 11:16:01 2010
Shutting down archive processes
Fri Feb 05 11:16:06 2010
ARCH shutting down
ARC2: Archival stopped
Similar Messages
-
Complex Query which needs tuning
Hello :
I have a complex query that needs to be tuned. I have little experience in tuning the sql and hence taking the help of your guys.
The Query is as given below:
Database version 11g
SELECT DISTINCT P.RESPONSIBILITY, P.PRODUCT_MAJOR, P.PRODUCT_MINOR,
P.PRODUCT_SERIES, P.PRODUCT_CATEGORY AS Category1, SO.REGION_CODE,
SO.STORE_CODE, S.Store_Name, SOL.PRODUCT_CODE, PRI.REPLENISHMENT_TYPE,
PRI.SUPPLIER_CODE,
SOL.SOLD_WITH_NIC, SOL.SUGGESTED_PRICE,
PRI.INVOICE_COST, SOL.FIFO_COST,
SO.ORDER_TYPE_CODE, SOL.DOCUMENT_NUM,
SOS.SLSP_CD, '' AS FNAME, '' AS LNAME,
SOL.PRICE_EXCEPTION_CODE, SOL.AS_IS,
SOL.STATUS_DATE,
Sum(SOL.QUANTITY) AS SumOfQUANTITY,
Sum(SOL.EXTENDED_PRICE) AS SumOfEXTENDED_PRICE
--Format([SALES_ORDER].[STATUS_DATE],"mmm-yy") AS [Month]
FROM PRODUCT P,
PRODUCT_MAJORS PM,
SALES_ORDER_LINE SOL,
STORE S,
SALES_ORDER SO,
SALES_ORDER_SPLITS SOS,
PRODUCT_REGIONAL_INFO PRI,
REGION_MAP R
WHERE P.product_major = PM.PRODUCT_MAJOR
and SOL.PRODUCT_CODE = P.PRODUCT_CODE
and SO.STORE_CODE = S.STORE_CODE
AND SO.REGION_CODE = S.REGION_CODE
AND SOL.REGION_CODE = SO.REGION_CODE
AND SOL.DOCUMENT_NUM = SO.DOCUMENT_NUM
AND SOL.DELIVERY_SEQUENCE_NUM = SO.DELIVERY_SEQUENCE_NUM
AND SOL.STATUS_CODE = SO.STATUS_CODE
AND SOL.STATUS_DATE = SO.STATUS_DATE
AND SO.REGION_CODE = SOS.REGION_CODE
AND SO.DOCUMENT_NUM = SOS.DOCUMENT_NUM
AND SOL.PRODUCT_CODE = PRI.PRODUCT_CODE
AND PRI.REGION_CODE = R.CORP_REGION_CODE
AND SO.REGION_CODE = R.DS_REGION_CODE
AND P.PRODUCT_MAJOR In ('STEREO','TELEVISION','VIDEO')
AND SOL.STATUS_CODE = 'D'
AND SOL.STATUS_DATE BETWEEN '01-JUN-09' AND '30-JUN-09'
AND SO.STORE_CODE NOT IN
('10','20','30','40','70','91','95','93','94','96','97','98','99',
'9V','9W','9X','9Y','9Z','8Z',
'8Y','92','CZ','FR','FS','FT','FZ','FY','FX','FW','FV','GZ','GY','GU','GW','GV','GX')
GROUP BY
P.RESPONSIBILITY, P.PRODUCT_MAJOR, P.PRODUCT_MINOR, P.PRODUCT_SERIES, P.PRODUCT_CATEGORY,
SO.REGION_CODE, SO.STORE_CODE, /*S.Short Name, */
S.Store_Name, SOL.PRODUCT_CODE,
PRI.REPLENISHMENT_TYPE, PRI.SUPPLIER_CODE,
SOL.SOLD_WITH_NIC, SOL.SUGGESTED_PRICE, PRI.INVOICE_COST,
SOL.FIFO_COST, SO.ORDER_TYPE_CODE, SOL.DOCUMENT_NUM,
SOS.SLSP_CD, '', '', SOL.PRICE_EXCEPTION_CODE,
SOL.AS_IS, SOL.STATUS_DATE
Explain Plan:
SELECT STATEMENT, GOAL = ALL_ROWS Cost=583 Cardinality=1 Bytes=253
HASH GROUP BY Cost=583 Cardinality=1 Bytes=253
FILTER
NESTED LOOPS Cost=583 Cardinality=1 Bytes=253
HASH JOIN OUTER Cost=582 Cardinality=1 Bytes=234
NESTED LOOPS
NESTED LOOPS Cost=571 Cardinality=1 Bytes=229
NESTED LOOPS Cost=571 Cardinality=1 Bytes=207
NESTED LOOPS Cost=569 Cardinality=2 Bytes=368
NESTED LOOPS Cost=568 Cardinality=2 Bytes=360
NESTED LOOPS Cost=556 Cardinality=3 Bytes=435
NESTED LOOPS Cost=178 Cardinality=4 Bytes=336
NESTED LOOPS Cost=7 Cardinality=1 Bytes=49
HASH JOIN Cost=7 Cardinality=1 Bytes=39
VIEW Object owner=CORP Object name=index$_join$_015 Cost=2 Cardinality=3 Bytes=57
HASH JOIN
INLIST ITERATOR
INDEX UNIQUE SCAN Object owner=CORP Object name=PRODMJR_PK Cost=0 Cardinality=3 Bytes=57
INDEX FAST FULL SCAN Object owner=CORP Object name=PRDMJR_PR_FK_I Cost=1 Cardinality=3 Bytes=57
VIEW Object owner=CORP Object name=index$_join$_016 Cost=4 Cardinality=37 Bytes=740
HASH JOIN
INLIST ITERATOR
INDEX RANGE SCAN Object owner=CORP Object name=PRDMNR1 Cost=3 Cardinality=37 Bytes=740
INDEX FAST FULL SCAN Object owner=CORP Object name=PRDMNR_PK Cost=4 Cardinality=37 Bytes=740
INDEX UNIQUE SCAN Object owner=CORP Object name=PRODMJR_PK Cost=0 Cardinality=1 Bytes=10
MAT_VIEW ACCESS BY INDEX ROWID Object owner=CORP Object name=PRODUCTS Cost=171 Cardinality=480 Bytes=16800
INDEX RANGE SCAN Object owner=CORP Object name=PRD2 Cost=3 Cardinality=681
TABLE ACCESS BY INDEX ROWID Object owner=DS Object name=SALES_ORDER_LINE Cost=556 Cardinality=1 Bytes=145
BITMAP CONVERSION TO ROWIDS
BITMAP INDEX SINGLE VALUE Object owner=DS Object name=SOL2
TABLE ACCESS BY INDEX ROWID Object owner=DS Object name=SALES_ORDER Cost=4 Cardinality=1 Bytes=35
INDEX RANGE SCAN Object owner=DS Object name=SO1 Cost=3 Cardinality=1
TABLE ACCESS BY INDEX ROWID Object owner=DS Object name=REGION_MAP Cost=1 Cardinality=1 Bytes=4
INDEX RANGE SCAN Object owner=DS Object name=REGCD Cost=0 Cardinality=1
MAT_VIEW ACCESS BY INDEX ROWID Object owner=CORP Object name=PRODUCT_REGIONAL_INFO Cost=2 Cardinality=1 Bytes=23
INDEX UNIQUE SCAN Object owner=CORP Object name=PRDRI_PK Cost=1 Cardinality=1
INDEX UNIQUE SCAN Object owner=CORP Object name=BI_STORE_INFO_PK Cost=0 Cardinality=1
MAT_VIEW ACCESS BY INDEX ROWID Object owner=CORP Object name=BI_STORE_INFO Cost=1 Cardinality=1 Bytes=22
VIEW Object owner=DS cost=11 Cardinality=342 Bytes=1710
HASH JOIN Cost=11 Cardinality=342 Bytes=7866
MAT_VIEW ACCESS FULL Object owner=CORP Object name=STORE_CORP Cost=5 Cardinality=429 Bytes=3003
NESTED LOOPS Cost=5 Cardinality=478 Bytes=7648
MAT_VIEW ACCESS FULL Object owner=CORP Object name=STORE_GROUP Cost=5 Cardinality=478 Bytes=5258
INDEX UNIQUE SCAN Object owner=CORP Object name=STORE_REGIONAL_INFO_PK Cost=0 Cardinality=1 Bytes=5
INDEX RANGE SCAN Object owner=DS Object name=SOS_PK Cost=2 Cardinality=1 Bytes=19
Regards,
BMPFirst thing that i notice in this query is you are Using Distinct as well as Group by.
Your group by will always give you distinct results ,then again why do you need the Distinct?
For example
WITH t AS
(SELECT 'clm1' col1, 'contract1' col2,10 value
FROM DUAL
UNION ALL
SELECT 'clm1' , 'contract1' ,10 value
FROM DUAL
UNION ALL
SELECT 'clm1', 'contract2',10
FROM DUAL
UNION ALL
SELECT 'clm2', 'contract1',10
FROM DUAL
UNION ALL
SELECT 'clm3', 'contract1',10
FROM DUAL
UNION ALL
SELECT 'clm4', 'contract2',10
FROM DUAL)
SELECT distinct col1,col2,sum(value) from t
group by col1,col2Is always same as
WITH t AS
(SELECT 'clm1' col1, 'contract1' col2,10 value
FROM DUAL
UNION ALL
SELECT 'clm1' , 'contract1' ,10 value
FROM DUAL
UNION ALL
SELECT 'clm1', 'contract2',10
FROM DUAL
UNION ALL
SELECT 'clm2', 'contract1',10
FROM DUAL
UNION ALL
SELECT 'clm3', 'contract1',10
FROM DUAL
UNION ALL
SELECT 'clm4', 'contract2',10
FROM DUAL)
SELECT col1,col2,sum(value) from t
group by col1,col2And also
AND SOL.STATUS_DATE BETWEEN '01-JUN-09' AND '30-JUN-09'It would be best to use a to_date when hard coding your dates.
Edited by: user5495111 on Aug 6, 2009 1:32 PM -
Working with multiple results of a complex query
Hi all!
As I "advance" in learning PL/SQL with oracle, I now get stuck in handling multiple results of a complex query. As far as I know, I cannot use a cursor here, as there is no table where the cursor could point to.
Here is the concept of what I want to do (pseudocode):
foreach result in SELECT * FROM table_1, table_n WHERE key_1 = foreign_key_in_n;
-- do someting with the resultHere is my attemt, that freezes the browser gui and throws an internal database error:
declare
type t_stock is record(
baggage_id baggage.baggage_id%type,
section_id sections.section_id%type,
shelf_id shelves.shelf_id%type
v_stock t_stock;
rcnt number(2);
begin
dbms_output.put_line(TO_CHAR(rcnt));
loop
SELECT COUNT(*) INTO rcnt FROM (
SELECT baggage.baggage_id, sections.section_id, shelves.shelf_id
FROM baggage, sections, shelves
WHERE baggage.baggage_id = sections.contained_baggage_id
AND shelves.is_connex_to_section_id = sections.section_id);
IF rcnt <= 0 THEN
exit;
END IF;
SELECT baggage.baggage_id, sections.section_id, shelves.shelf_id INTO v_stock
FROM baggage, sections, shelves
WHERE baggage.baggage_id = sections.contained_baggage_id
AND shelves.is_connex_to_section_id = sections.section_id
AND ROWNUM < 2;
UPDATE sections SET contained_baggage_id = NULL WHERE section_id = v_stock.baggage_id;
commit; -- do I need that?
end loop;
END;
/So, is there a way to traverse a list of results from a complex query? Maybe without creating a temporary table (or is that the better way?).
regards, Alex
I reformatted the code
pktmOk, here are the details:
The tables are used to model kind of a transport system. There are terminals connected with sections that may contain 1 piece of baggage. The baggage is moved by a procedure through a transport system. After each of these "moving steps", I check if the baggage is in front of the shelf it should be in.
[To be honest, the give statement doesn't contain the info, in which shelf the baggage wil bee inserted. That was spared out because of the lack of a working piece of code :)]
But: if we consider the fact, that a baggage is in front of such a shelf in the way, that it should be put in this shelf, then all this makes some sense.
- move baggae through a transport system
- see if you can put baggage into a shelf
In order to "put baggage in a shelf", I need to remove it from the transport section. As the transport system is not normalized, I need to update the section where the baggage was in.
Uhm... yes it's a task that doesn't make too much sense. It seems to be some kind of general spirit in university homework :)
But: the FOR r IN (Statement) lloks good. I'll use that.
And, the ROWNUM < 2 is used to limit the size of the result to 1, there is no need to have a specific ordering. It's just because - afaik - oracle doesn't have a limit clause. I would appreciate your help if you know a better way to do limit resultsets.
best regards, Alex -
Performance issue with this complex query
Please ignore this thread(post)
This query fetches a lot of data and takes more than 4 t0 5 hrs to retrieve them.
I have tried to get the explain plan the display cursor and the TKPROF for the same but then the query utilizes more than 100GB temp space and it fails to generate any.
What I have is the spool file which is pasted below along with the query.
Database version: 11g
I'm looking forward for suggestions how to improve the performance of this statement
Please ignore this thread(post)
Edited by: user13319084 on May 30, 2011 12:34 AMYou provide no information that can be used in answering your question on how to improve the query.
In absence of technical information, all that we can discuss is conceptual issues. Like why is the query that complex? A common answer is that the underlying data model lacks the intelligence and this now requires the intelligence to be build into the query.
You need to look at the data model and the query in order to address this performance problem - and make sure that the actual business requirements is clearly identified and understood. -
Hi,
I'm new in Enterprise javabeans, I have been looking for (almost five days) the
best way to get the result for a complex query. I tried with example Weblogic
BeanManaged. I put the query directly in a method in entityBean class with prepareStatament
and that worked.
But, I have to evaluate the best way to get result with EJB's. So, I think that
I have to evaluate others like containerManaged, in this case I have to define
each entity Bean and relationships and everything, isn't it?
Is there another way to develop it with good results? and fast?
If someone have any good idea to develop a solution with EJB's for this query.
I'm really appreciate it.
select CU.ID_CUENTA_USO, C.CLASE_CUENTA, C.ESTADO, P.ID_PRODUCTO, P.NOMBRE_PRODUCTO,
CU.ID_TIPO_PAGO, AOA.ID_AREA, AOA.NOMBRE_AREA, AOA.ID_TIPO_AOA, CU.ID_CLIENTE_USUARIO,
decode (PN.ID_PERSONA,null, decode (PJ.ID_PERSONA,null, PR.APELLIDOS || ' ' ||PR.NOMBRES,
PJ.NOMBRE_EMPRESA),PN.APELLIDOS || ' ' ||PN.NOMBRES)
from ATRIBUTOS A, CUENTA_USO CU, CUENTA C, PRODUCTO P,
AREA_OPERACIONES_ADM AOA, PERSONA_NATURAL PN, PERSONA_JURIDICA PJ, PERSONA_REPRESENTADO
PR
where A.ABREVT_ATRIB_CTA_USO = 'NRO_CELULAR'
and A.VALOR = '142000000'
and CU.ID_CUENTA_USO = A.ID_CUENTA_USO
and C.ID_CUENTA = CU.ID_CUENTA_USO
and P.ID_PRODUCTO = CU.ID_PRODUCTO
and AOA.ID_AREA(+) = CU. ID_AREA_ACTIVACION
and AOA.ID_TIPO_AOA(+) = CU.ID_TIPO_AREA_ACTIVACION
and PN.ID_PERSONA(+) = CU.ID_CLIENTE_USUARIO
and PJ.ID_PERSONA(+) = CU.ID_CLIENTE_USUARIO
and PR.ID_PERSONA(+) = CU.ID_CLIENTE_USUARIO
order
by P.ID_PRODUCTO, CU.ID_CUENTA_USO;
Thank's in advanced
YoseHola/Hello Ryan
Muchas Gracias por tu respuesta/ Thank's a lot for your answer, I'm trying with
relationship-caching but something is missing.. because i got an error:
ejbc:
[java] [EJBCompiler] : Recompiling because no previous hashes found
[java] [EJBCompiler] : Compliance Checker said bean was compliant
[java]
[java]
[java]
[java] ERROR: Error from ejbc: While reading META-INF/weblogic-cmp-rdbms-jar.xml,
the Entity EJB's peristence layer failed to deploy. The error was:
[java] Error in descriptor line 44: Element type "relationship-caching"
must be declared.
[java]
[java]
[java] ERROR: ejbc found errors
I have two EJB Cuenta and Atributo I defined a relationship in the weblogic-cmp-rdbms-jar.
(I want to start with two entity and add later the others producto, cuenta, persona_x)
<relationship-caching>
<caching-name>Cuenta-Atributo</caching-name>
<caching-element>
<cmr-field>cuenta</cmr-field>
<group-name>cuentas_group</group-name>
<caching-element>
<cmr-field>atributos</cmr-field>
<group-name>atrib_group</group-name>
</caching-element>
</caching-element>
</relationship-caching>
Where i have to defined it? Thanks a lot for your help..
Yosemarlyn
"Ryan LeCompte" <[email protected]> wrote:
>
Hola/Hello Yosemarlyn,
You can utilize EJB 2.0 CMP to model the query that you specified. You
would model
the business domain as CMP Entity beans and then specify the various
relationships
among them. You actually may get an increase in performance by utilizing
CMP/CMR
in WebLogic due to the new features such as relationship caching, optimistic
concurrency
strategy support, etc. Utilizing these features will drastically reduce
the number
of SQL Joins (and overall hits to the database, due to caching). Below
are various
links for learning more:
Mastering EJB II (Good book for learning about CMP/CMR):
http://www.theserverside.com/books/masteringEJB/index.jsp
Optimistic Concurrency:
http://dev2dev.bea.com/resourcelibrary/technicalguides/Optimistic_Concurrency.jsp
http://edocs.bea.com/wls/docs70/ejb/EJB_environment.html#1153757
Relationship caching:
http://edocs.bea.com/wls/docs70/ejb/EJB_environment.html#1151177
Espero que esto te sirva bien. :-)
Saludos,
Ryan LeCompte
[email protected]
http://www.louisiana.edu/~rml7669
"Yosemarlyn Lopez" <[email protected]> wrote:
Hi,
I'm new in Enterprise javabeans, I have been looking for (almost five
days) the
best way to get the result for a complex query. I tried with example
Weblogic
BeanManaged. I put the query directly in a method in entityBean class
with prepareStatament
and that worked.
But, I have to evaluate the best way to get result with EJB's. So, I
think that
I have to evaluate others like containerManaged, in this case I have
to define
each entity Bean and relationships and everything, isn't it?
Is there another way to develop it with good results? and fast?
If someone have any good idea to develop a solution with EJB's for this
query.
I'm really appreciate it.
select CU.ID_CUENTA_USO, C.CLASE_CUENTA, C.ESTADO, P.ID_PRODUCTO, P.NOMBRE_PRODUCTO,
CU.ID_TIPO_PAGO, AOA.ID_AREA, AOA.NOMBRE_AREA, AOA.ID_TIPO_AOA, CU.ID_CLIENTE_USUARIO,
decode (PN.ID_PERSONA,null, decode (PJ.ID_PERSONA,null, PR.APELLIDOS
|| ' ' ||PR.NOMBRES,
PJ.NOMBRE_EMPRESA),PN.APELLIDOS || ' ' ||PN.NOMBRES)
from ATRIBUTOS A, CUENTA_USO CU, CUENTA C, PRODUCTO P,
AREA_OPERACIONES_ADM AOA, PERSONA_NATURAL PN, PERSONA_JURIDICA PJ, PERSONA_REPRESENTADO
PR
where A.ABREVT_ATRIB_CTA_USO = 'NRO_CELULAR'
and A.VALOR = '142000000'
and CU.ID_CUENTA_USO = A.ID_CUENTA_USO
and C.ID_CUENTA = CU.ID_CUENTA_USO
and P.ID_PRODUCTO = CU.ID_PRODUCTO
and AOA.ID_AREA(+) = CU. ID_AREA_ACTIVACION
and AOA.ID_TIPO_AOA(+) = CU.ID_TIPO_AREA_ACTIVACION
and PN.ID_PERSONA(+) = CU.ID_CLIENTE_USUARIO
and PJ.ID_PERSONA(+) = CU.ID_CLIENTE_USUARIO
and PR.ID_PERSONA(+) = CU.ID_CLIENTE_USUARIO
order
by P.ID_PRODUCTO, CU.ID_CUENTA_USO;
Thank's in advanced
Yose
[weblogic-cmp-rdbms-jar.xml] -
How to query a database file on my hard drive?
Hi,
I have a filer called "server.dbs" on my hard drive. It is a database file. I use a simple program that allows you to view databases, and it loads up and I can traverse the database and see all the entries as any standard database.
So I figured that Java's ability to handle SQL would allow me to make a standard SQL statement querying the database, and be able to get the results. The software stores servers in SID fields, and the value is the port the server runs on. I want to make a simple query to select a server by SID, and print the port in which that server is running on.
So is there any way to, via my java application, load a database from a file (rather than a url) which has no authentication required, and simply make my queries directly to that file? If so, how?
Thanks!
-JoshNormal database access is via JDBC.
http://java.sun.com/docs/books/tutorial/jdbc/index.html
To use that JDBC driver is needed to access the database. Databases in wide usage all have one. It isn't clear from your posting that you have a common database though. -
1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed in the stat plan ?
2. Does rowsource statistics gives some kind of understanding of Extended stats ?You can get Row Source Statistics only *after* the SQL has been executed. An Explain Plan midway cannot give you row source statistics.
To get row source statistics either set STATISTICS_LEVEL='ALL' in the session that executes theSQL OR use the Hint "gather_plan_statistics" in the SQL being executed.
Then use dbms_xplan.display_cursor
Hemant K Chitale -
Build dynamic SQL query in Database Adapter.
Hi All,
I have a requirement to build dynamic sql query at Database Adapter.
My BPEL process is getting search spec as input from siebel. I need to process this searchspec in BPEL and need to build the SQL query dynamically at Database Adapter to fetch the records from DB.
it goes like this....
1. Sieble Search Spec: city1 OR city2 OR city3 OR city4 .....
I need to build query as
select * from S_ADDR_PER where city like 'city1' OR city like 'city2' OR city like 'city3' OR city like 'city4' ......
2. Siebel Search spec: city1 AND country1 AND state1....
I need to build query as
Select * from S_ADDR_PER where city like 'city1' AND country like 'country1' AND state like 'state1' ....
3. Siebel Search spec: state
I need to build query as
select * from S_ADDR_PER where state like '%state%';
Is it feasible in Database Adapter? if its Yes.
Any guidelines to achieve this?
Thank you
ChandraHi All,
I have a requirement to build dynamic sql query at Database Adapter.
My BPEL process is getting search spec as input from siebel. I need to process this searchspec in BPEL and need to build the SQL query dynamically at Database Adapter to fetch the records from DB.
it goes like this....
1. Sieble Search Spec: city1 OR city2 OR city3 OR city4 .....
I need to build query as
select * from S_ADDR_PER where city like 'city1' OR city like 'city2' OR city like 'city3' OR city like 'city4' ......
2. Siebel Search spec: city1 AND country1 AND state1....
I need to build query as
Select * from S_ADDR_PER where city like 'city1' AND country like 'country1' AND state like 'state1' ....
3. Siebel Search spec: state
I need to build query as
select * from S_ADDR_PER where state like '%state%';
Is it feasible in Database Adapter? if its Yes.
Any guidelines to achieve this?
Thank you
Chandra -
Dynamically Pass sql query in Database adapter
hi',
How can we dynamically pass sql query in Database adapter, is there any way, I am using SOA 11G.
Thanks
YatanHi,
Tried that too. No luck. Gives me this.
The selected operation process could not be invoked.
An exception occured while invoking the webservice operation. Please see logs for more details.
oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'selectUsingIn' failed due to: Pure SQL Exception.
Pure SQL Execute of select interface_id, property_name, property_value from ( (?) ) failed.
Caused by java.sql.SQLSyntaxErrorException: ORA-00903: invalid table name
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
Regards,
Neeraj Sehgal -
Can a web service query a database at set intervals?
Can someone verify if this is feasible?
I need to display live data via browsers . I would like to have the query to the database executed server side and have the web service provide the data to the browsers.
Here is what I propose :
I would like to have a web service run on a web server for an intranet.
Have the web service query a database every 20 seconds and update the data into a table or an array variable.
On the browser side I want the browser to refresh every 20 seconds with the updated data from the web service.
Any other recommendations would be greatly appreciated.
Thank you.
Chris W.Hi ChrisTW1,
Thank you for posting in MSDN forum.
Based on your issue, I suggest you can try to use the JS to call the web service to set the intervals. For more information about how to use the JS to call the web service to set the intervals, please see:
http://www.codeproject.com/Tips/647322/Calling-ASP-NET-Webservice-using-JavaScript-on-Reg
In addition, since
this forum is to discuss: Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor. If you have any issues about the set the
intervals for the web service, I suggest you can post this issue directly to the WCF forum:https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf, maybe
you will get more help.
Hope it help you!
Best Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Query distributed database with different character sets.
Hello experts, this is my situation:
I have two databases A and B, the same version 11.1.0.7, the same OS Suse Linux Enterprise 10 but with different character sets, A has WE8MSWIN1252 while B has AL32UTF8. The database B is my XML DB repository so there I have some XML type tables. I need to query this tables from the database A using a dblink and in fact I have done that but the XML content is trasformed due to the different character sets between the databases. Some time there are data loss and some time there are data missmatch.
Is there any way to query the tables stored in the database B without problems? I do not know if the following is correct: Maybe I can set the character set for the session in the database A during the time it query the database B. That is, change the character set in fly at session level.
Do you have any special suggestion?
I hope you can help me, thank you in advance.The Globalization Support Guide for 11.1.0.7 has a chapter on character set migration that should be helpful. AL32UTF8 is a superset of WE8MSWIN1252 but it is not a strict superset. That is, it doesn't meet the second prong of the test in the documentation
The new character set is a strict superset of the current character set if:
Each and every character in the current character set is available in the new character set.
Each and every character in the current character set has the same code point value in the new character set. For example, many character sets are strict supersets of US7ASCII.Exporting the data from the A, changing the character set (or creating a new database with the AL32UTF8 character set), and then importing the data may be the easiest approach in your case.
Justin
Edited by: Justin Cave on Jan 13, 2011 12:08 PM -
Is it possible to query which databases are on a databaseserver
I am trying to create a list of databases to which a specified user can connect.
The user has to specify the database server, user name and password and I want to show a list of possible databases.
Can this be accomplished?
Thanks.Thanks for the help. The code below lists the databases in a MS SQL Server. For MySql I think the trick is to use the query "SHOW DATABASES;" with as column name 'Database', but I don't have a MySql Server here at this moment to test it.
public static List getDatabases(final Connection dbCon) throws Exception {
List databases = new ArrayList();
try {
String databaseName = null;
ResultSet rs;
Statement stat;
stat = dbCon.createStatement();
rs = stat.executeQuery("exec sp_databases");
while (rs.next()) {
databaseName = rs.getString("DATABASE_NAME");
if (!databases.contains(databaseName)) {
databases.add(databaseName);
} catch (SQLException e) {
throw new Exception("Get databases failed:" + e.getMessage());
return databases;
} -
Problems with query via Database-Link (Oracle 7.3.4)
I made the following simple query via database-link.
select count (*) from [email protected]
I got the result in about 200 miliseconds.
Then I4ve tried the following query.
select * from [email protected]
It took about 2 hours end ended with an error message "ORA-03113: end-of-file on communication channel"
So I made another choice
select * from [email protected] where rownum <=1
Took about 200 miliseconds.
So I made the query again an changed only the number of rownums,until I was at rownum <=8
then it went sleeping again(I've canceled the statement because I didn't want to wait 2 hours again).
We made the same things from another server with the same database-link on the same remote server
and we had no problems.
Any Idea???No, network is OK!
Other links are running, I have also no problems when I connect directly to the remote server. -
I am novice in PL/Sql. I need some help in writing a complex query.
I imagine the following table structure.
Type(string) Date(date) count(int)
Given a date range
The query needs to group the records on type and return the record (type and count) which has the max date (its just date, no time is involved) for each group (which is based on type) . If there are more than one records which have the max date then the average count should be returned for that type
i would be glad if someone could give any ideas as to how to go about this query. Thanking you in advance.
regards.Heres the query ... Forget the period .... wht this query is supposed to do is group on assigned ki for a given date range. then it has to get the value which is for the last record for that Ki in the date range. If there are 2 records which have max date then it should give an average.
e.g
assignedKI / date / value
a 1st may 2008 10
b 2nd may 2008 12
c 1st may 2008 13
a 30 - apr-2008 16
b 4th may 2008 17
a 1st may 2008 20
The query should return
a 1st may 2008 15 (which is the average as there are 2 values for the max date for a)
b 4th may 2008 17
c 1st may 2008 13
the following query doesnot work ....
SELECT
kiv2.assigned_k_i,
kiv2.ki_name,
kiv.period,
max( kiv2.ki_value_date) ,
avg(kiv2.ki_value)
FROM
SELECT
assigned_k_i,
period p1,
TO_CHAR(ki_value_date, period) period,
MAX(ki_value_date) ki_value_date
FROM
v_ki_value,
(select ? period from dual)
WHERE
(status = 'APPROVED' OR status = 'AUTOAPPROVED')
AND ( trunc(to_date(to_char(ki_value_date, 'DD/MM/YYYY'), 'DD/MM/YYYY')) >= ?)
AND ( trunc(to_date(to_char(ki_value_date, 'DD/MM/YYYY'), 'DD/MM/YYYY')) <= ?)
AND (INSTR(?, TO_CHAR(assigned_k_i)) > 0)
GROUP BY
assigned_k_i,
TO_CHAR(ki_value_date, period)
) kiv,
v_ki_value kiv2
WHERE
kiv.assigned_k_i = kiv2.assigned_k_i
AND to_char(kiv.ki_value_date, kiv.p1) = to_char(kiv2.ki_value_date, kiv.p1)
GROUP BY
kiv2.assigned_k_i,
kiv2.ki_name,
kiv.period,
kiv2.ki_value
ORDER BY
kiv2.assigned_k_i -
How to bind local variables in complex query in PL/SQL
Hi
I have long complex query with local varibales; when I run in Dynamic SQL I get an error. Not sure which is the easiest way to bind local variables.
L_QUERY := q'[select m.segment1 col1,
'1' col2,
'13' col3,
l.operand col4,
0 col5,
'Y' col8,
'N' col9,
'N' col10,
decode(h.name,'09_UKOR_*','EOS Credit','10_UKOR_*','TopUp','11_UKOR_*','Main') col18
from qp_list_headers_v h,
qp_list_lines_v l,
mtl_system_items m
where h.name in ('09_UKOR_*','10_UKOR_*','11_UKOR_*')
and h.list_header_id = l.list_header_id
and m.inventory_item_id = l.product_attr_value
and m.organization_id = 84
UNION all
SELECT qs.PRODUCT_ATTR_VALUE col1,
hca.account_number col2,
decode (su.site_use_code,'BILL_TO','21','SHIP_TO','18') col3,
0 col4,
qs.operand col5,
null col6,
null col7,
'N' col8,
'Y' col9,
'N' col10,
--Local variables
(case when (trunc(nvl(qq.start_date_active,sysdate)) between l_cur_year_from and l_cur_year_to) and
( trunc(nvl(qq.end_date_active,l_cur_year_to)) >= trunc(l_cur_year_to) ) then 'TopUp'
when (trunc(qq.start_date_active) between l_next_year_from and l_next_year_to) and
( trunc(nvl(qq.end_date_active,l_next_year_to)) >= l_next_year_to) then 'Main'
when (trunc(qq.start_date_active) between l_last_year_from and l_last_year_to) and
( trunc(nvl(qq.end_date_active,l_last_year_to)) >= l_last_year_to ) then 'EOS Return'
end )col18,
--Local variables
(case when (trunc(qq.start_date_active) between l_next_year_from and l_next_year_to) and
( trunc(nvl(qq.end_date_active,l_next_year_to)) >= l_cur_year_to ) then 'N'
else
'Y' end ) col21
FROM qp.qp_list_headers_b qlhb,
qp.qp_list_headers_tl qlht,
qp.qp_qualifiers qq,
qp_modifier_summary_v qs,
hz_cust_site_uses_all su,
hz_cust_acct_sites_all sa,
hz_cust_accounts hca
WHERE 1=1
and qlhb.LIST_TYPE_CODE = 'DLT'
and nvl(qlhb.active_flag,'Y') = 'Y'
and qlhb.list_header_id = qlht.list_header_id
AND qq.list_header_id = qlhb.list_header_id
and qq.list_type_code = qlhb.LIST_TYPE_CODE
and qq.QUALIFIER_CONTEXT = 'CUSTOMER'
and qs.list_header_id = qlhb.list_header_id
and qs.LIST_LINE_TYPE_CODE = 'DIS'
and su.site_use_id = qq.qualifier_attr_value --1064
AND su.cust_acct_site_id = sa.cust_acct_site_id
AND sa.cust_account_id = hca.cust_account_id ]';
--call Dynamic SQL function
l_cursor := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(l_cursor, p_QUERY , DBMS_SQL.NATIVE);
l_rows := DBMS_SQL.EXECUTE(l_cursor);
Any help will be much appreciated.
iI guess I should use DBMS_SQL.BIND_VARIABLE to bind all variables seperately so not to mess with query1) What is the error you get?
2) If you use bind variables inside a query, you should prefix them with colons, so use :l_cur_year_from etc.
3) Why are you using dbms_sql instead of native dynamic sql and/or ref-cursors?
Toon
Maybe you are looking for
-
after updating to firefox 8.0, can not send gifts or requests from farmville or cityville on facebook. (When I hit the send button I get an empty window titled "about:blank", which disappears and nothing gets sent. It works under internet explorer bu
-
I would like to cancel my subscription immediately
I would like to cancel my subscription because I do not have Word to even export the files. Thank you
-
Please correct this code public class obj{ private String objval; public obj(String val) objval=val; public String tostring() return objval; public static void Change(obj o,int i); o.objval="value 2"; o= new objval("value3"); o.objval="value 4"; i=2;
-
Is Oracle Developer 10g certified with Windows 7 and IE-8 ?
Hi All, Is Oracle Developer 10g certified with Windows 7 and IE-8 ? Regards,
-
Required Packages For Database Install
I'm installing a new 11.2.0.3 database on RHEL 6.3 64-bit tomorrow and I've got the base installation done and I've followed the following doc. to verify my Linux system has all the appropriate packages however in order to run the OUI (Oracle Univers