What is @ in a Select Query?
I am trying to understand the use of @ symbol and xxxxx in the folowing query...
select Col1, Col2, Col3 FROM school.MyTable@xxxxx
In addition to Riedelme:
Distributed Database Concepts
common documentation, fully searcheable, is here:
Oracle Database Online Documentation 11g Release 2 (11.2)
latest release (check the new features):
Oracle Database Online Documentation 12c Release 1 (12.1)
Similar Messages
-
Need some help with the Select query.
Need some help with the Select query.
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
select single vkorg abgru from ZADS into it_rej.
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
This is causing performance issue. They are asking me to include the where condition for this select query.
What should be my select query here?
Please suggest....
Any suggestion will be apprecaiated!
Regards,
DeveloperHello Everybody!
Thank you for all your response!
I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table
select vkorg abgru from ZADS into it_rej.
Earlier :
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
Now :
DATA : BEGIN OF IT_REJ occurs 0,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
I guess this will fix the issue correct?
PLease suggest!
Regards,
Developer. -
Please explain this select query
Hello Experts
please see this select query.
select * from kna1 where lifnr = '1111111101'.
while debugging how to see what records this above select query has fetched. please explain me.
Thanks for all the repliesHi madan,
as explained, you need an ENDSELECT which I think you already have. In debugger, you could see the records fetched between SELECT and ENDSELECT but you will probably get a DUMP because a forbidden database access interrupt is detected.
If your program does not process the records you have no chance to see them.
A possible solution is:
data:
lt_kunnr type table of kna1-kunnr.
select * from kna1 where lifnr = '1111111101'.
append kna1-kunnr to lt_kunnr.
endselect.
Now you have the primary key KUNNR of all records fetched in table lt_kunnr.
Regards,
Clemens -
How should I change the following SELECT QUERY?
Requirement:
There are checks in the program for material group 2, z93 AND z94 which should be skipped if the sales org = 'JP40'.
sales organisation is taken from the layout(SE51) dictionary fields (MODULE POOL PROGRAM)
The select query is:
select single matnr
into t_mvke-matnr "dummy
from mvke
where matnr = t_9000-matnr
and vkorg = vbak-vkorg
and vtweg = vbak-vtweg
and mvgr2 in (c_z93,c_z94).
How should I skip the material group c_z93, c_z94 only for JP40(vbak-vkorg) sales organisation, except JP40 material group should be there for other sales org. but for JP40 material group should be skipped.
What would be the select query or should I give any kind of IF conditions before select query.
Please help me out.Hi Rani K
You can try like
IF VBAK-VKORG = 'JP40'.
select single matnr
into t_mvke-matnr "dummy
from mvke
where matnr = t_9000-matnr
and vkorg = vbak-vkorg
and vtweg = vbak-vtweg.
ELSE.
select single matnr
into t_mvke-matnr "dummy
from mvke
where matnr = t_9000-matnr
and vkorg = vbak-vkorg
and vtweg = vbak-vtweg
and mvgr2 in (c_z93,c_z94).
ENDIF.
Thanks
Gaurav -
What is the wrong with my select query
HI All,
TYPES: BEGIN OF t_equi,
equnr TYPE equi-equnr,
aedat TYPE equi-aedat,
matnr TYPE equi-matnr,
sernr TYPE equi-sernr,
kunde TYPE equi-kunde,
zzreg_date TYPE equi-zzreg_date,
zzin_indic TYPE equi-zzin_indic,
zzinvoice_num TYPE equi-zzinvoice_num,
zzinvoice_date TYPE equi-zzinvoice_date,
kund1 TYPE equz-kund1,
END OF t_equi,
DATA: it_equi TYPE TABLE OF t_equi,
SELECT equnr
aedat
matnr
sernr
kunde "Ship to
zzreg_date
zzin_indic
zzinvoice_num
zzinvoice_date
kund1 "Sold to
INTO TABLE it_equi
FROM equi AS a
INNER JOIN equz AS b
ON a~equnr = b~equnr
WHERE a~equnr IN s_equnr AND
* aedat GE gv_rdate AND
a~matnr IN s_matnr AND
a~sernr IN s_sernr AND
a~kunde IN r_shpbr_kunde AND
a~zzin_indic IN s_indic AND
b~datbi EQ c_datbi AND
b~kund1 IN r_sldbr_kund1 .
what is the wrong with this select query.. ?
its giving me error "The column name "EQUNR" is unclear ."
ThanksHi ,
write tablename or alias in select also
SELECT a~equnr and check.
Regards -
What can i do for removing SINGLE in this select query??
What can i do for removing SINGLE in this select query given below and also NOT USE 'ENDSELECT'??
I have defined g_t_zv7_cachemapping as following ::
DATA : BEGIN OF g_t_zv7_cachemapping OCCURS 0,
kostl LIKE zv7_cachemapping-kostl,
END OF g_t_zv7_cachemapping.
SELECT SINGLE kostl FROM zv7_cachemapping INTO g_t_zv7_cachemapping
WHERE auart = g_t_vbak-auart.
IF sy-subrc = 0 .
ENDIF.Shashank,
DATA : BEGIN OF g_t_zv7_cachemapping OCCURS 0,
AUART LIKE zv7_cachemapping-AUART,
kostl LIKE zv7_cachemapping-kostl,
END OF g_t_zv7_cachemapping.
If not g_t_vbak[] is initial.
SELECT auart kostl
FROM zv7_cachemapping INTO table g_t_zv7
for all entries in g_t_vbak
WHERE auart = g_t_vbak-auart.
Endif.
sort : g_t_zv7 by auart ,
g_t_vbak by auart.
loop at g_t_vbak.
READ TABLE g_t_zv7 WITH KEY AUART = g_t_vbak-AUART
BINARY SEARCH.
IF sy-subrc eq 0.
ENDIF.
endloop.
Pls. reward if useful -
Please help me what other way i can tune this select query..
Hello Guru,
I have a select query which retrieve data from 10 tables and around 4 tables having 2-4 Lac record and rest are having 80,000 - 1 Lac record.
It is taking around 7-8 seconds to fetch 55000 record.
I was strictly told by the client that i should not use HINTS in my query. My query is below. Please help me what other way i can tune this select query..
select
CT.CUST_ID
,CT.ROMANISED_SURNAME
,CT.SURNAME
,CT.ROMANISED_GIVEN_NAME
,CT.GIVEN_NAME
,CT.ROMANISED_MIDDLE_NAME
,CT.MIDDLE_NAME
,CT.ROMANISED_NAME_SUFFIX
,CT.NAME_SUFFIX
,CT.ROMANISED_TITLE
,CT.TITLE
,CT.ROMANISED_NAME_INITIALS
,CT.NAME_INITIALS
,CT.NAME_TEXT
,CT.CUST_JRNY_ID
,RK.REMARK_TYPE
,RK.REMARK_ID+CT.CUST_ID as REMARK_ID
,RK.REMARK_STATUS
,RK.REMARK_TEXT
,RK.HOST_ONLY_IND
,RK.SUPERVISORY_IND
,RK.CUST_COMM_IND
,RK.REMARK_SEQ
,RK.REMARK_CODE
,RK.DEFAULT_CUST_REL_IND
,RK.DEFAULT_FLIGHT_SEG_REL_IND
,RK.IATA_CODE
,RK.ICAO_CODE
,CJ.RECORD_LOCATOR "SITA_RECORD_LOCATOR"
,Cjv.Record_Locator "ORIGINATOR_RECORD_LOCATOR"
,FS.TRAVELLING_GROUP_CODE
,CG.GROUP_NAME
FROM FLIGHT_LEG FL
,CUST_FLIGHT_LEG CFL
,CUST CT
,CUST_REMARK CTR
,REMARK RK
,FLIGHT_SEG_FLIGHT_LEG FSFL
,FLIGHT_SEG FS
,CUST_JRNY CJ
,CUST_JRNY_VERSION CJV
,CUST_GROUP CG
WHERE FL.OPR_FLIGHT_NUMBER = 1--I_OPR_FLIGHT_NUMBER
and FL.HISTORY_VERSION_NUMBER = 0
and FL.DEPARTURE_STATION_CODE = 'DEL'--I_DEPARTURE_STATION_CODE
and FL.DEPARTURE_DATETIME = TO_DATE('10-DEC-2012 18.45.00', 'DD-MON-YYYY HH24.MI.SS')
and FL.OPR_SERVICE_PROVIDER_CODE= 'AI'--i_opr_service_provider_code
and FL.OPR_FLIGHT_SUFFIX = 'A'--NVL(I_OPR_FLIGHT_SUFFIX, FL.OPR_FLIGHT_SUFFIX)
AND FL.FLIGHT_LEG_ID = CFL.FLIGHT_LEG_ID
AND CFL.CUST_ID = CT.CUST_ID
AND FL.FLIGHT_LEG_ID=FSFL.FLIGHT_LEG_ID
AND FSFL.FLIGHT_SEG_ID=FS.FLIGHT_SEG_ID
AND CT.CUST_ID = CTR.CUST_ID(+)
AND CTR.REMARK_ID = RK.REMARK_ID(+)
AND FL.CUST_JRNY_ID = CJ.CUST_JRNY_ID
and CJ.CUST_JRNY_ID = CJV.CUST_JRNY_ID
AND CG.CUST_JRNY_ID(+) = CT.CUST_JRNY_ID
AND CFL.HISTORY_VERSION_NUMBER = 0
AND CT.HISTORY_VERSION_NUMBER = 0
AND NVL(CTR.HISTORY_VERSION_NUMBER,0) = 0
AND NVL(RK.HISTORY_VERSION_NUMBER,0) = 0
AND FS.HISTORY_VERSION_NUMBER = 0
AND FSFL.HISTORY_VERSION_NUMBER = 0
-- AND CJ.HISTORY_VERSION_NUMBER = 0
and CJV.VERSION_NUMBER = 0 --- Need to check
AND NVL(CG.HISTORY_VERSION_NUMBER,0) = 0
order by CT.CUST_JRNY_ID,CT.CUST_ID;
The Tables having record:
select COUNT(*) from FLIGHT_LEG -----241756
select COUNT(*) from CUST_FLIGHT_LEG---632585
select COUNT(*) from CUST---240015
select COUNT(*) from CUST_REMARK---73724
select COUNT(*) from REMARK---73654
select COUNT(*) from FLIGHT_SEG_FLIGHT_LEG---241789
select COUNT(*) from FLIGHT_SEG----260004
select COUNT(*) from CUST_JRNY----74288
select COUNT(*) from CUST_JRNY_VERSION----74477
select COUNT(*) from CUST_GROUP----55819
Thanks,
HP..Plan hash value: 3771714931
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 10239 | 2949K| | 7515 (1)| 00:01:31 | | |
| 1 | SORT ORDER BY | | 10239 | 2949K| 3160K| 7515 (1)| 00:01:31 | | |
|* 2 | HASH JOIN | | 10239 | 2949K| | 6864 (1)| 00:01:23 | | |
| 3 | PARTITION HASH ALL | | 73687 | 1079K| | 417 (1)| 00:00:06 | 1 | 512 |
|* 4 | TABLE ACCESS FULL | CUST_JRNY_VERSION | 73687 | 1079K| | 417 (1)| 00:00:06 | 1 | 512 |
|* 5 | HASH JOIN | | 10239 | 2799K| | 6445 (1)| 00:01:18 | | |
| 6 | PARTITION HASH ALL | | 73654 | 863K| | 178 (1)| 00:00:03 | 1 | 512 |
| 7 | TABLE ACCESS FULL | CUST_JRNY | 73654 | 863K| | 178 (1)| 00:00:03 | 1 | 512 |
|* 8 | FILTER | | | | | | | | |
|* 9 | HASH JOIN RIGHT OUTER | | 10239 | 2679K| | 6267 (1)| 00:01:16 | | |
| 10 | PARTITION HASH ALL | | 55315 | 756K| | 137 (1)| 00:00:02 | 1 | 512 |
| 11 | TABLE ACCESS FULL | CUST_GROUP | 55315 | 756K| | 137 (1)| 00:00:02 | 1 | 512 |
|* 12 | FILTER | | | | | | | | |
|* 13 | HASH JOIN OUTER | | 10240 | 2540K| 2056K| 6129 (1)| 00:01:14 | | |
|* 14 | FILTER | | | | | | | | |
|* 15 | HASH JOIN RIGHT OUTER | | 10242 | 1930K| | 5531 (1)| 00:01:07 | | |
| 16 | INDEX FAST FULL SCAN | CUST_REMARK_PK | 73677 | 935K| | 190 (0)| 00:00:03 | | |
|* 17 | HASH JOIN | | 10257 | 1802K| | 5339 (1)| 00:01:05 | | |
|* 18 | HASH JOIN | | 10257 | 701K| | 3516 (1)| 00:00:43 | | |
|* 19 | HASH JOIN | | 3963 | 220K| | 2476 (1)| 00:00:30 | | |
|* 20 | HASH JOIN | | 3963 | 181K| | 1300 (1)| 00:00:16 | | |
| 21 | PARTITION HASH ALL | | 3963 | 131K| | 728 (1)| 00:00:09 | 1 | 512 |
|* 22 | TABLE ACCESS FULL | FLIGHT_LEG | 3963 | 131K| | 728 (1)| 00:00:09 | 1 | 512 |
|* 23 | INDEX FAST FULL SCAN| FLIGHT_SEG_FLIGHT_LEG_PK | 240K| 3059K| | 571 (1)| 00:00:07 | | |
| 24 | PARTITION HASH ALL | | 259K| 2531K| | 1175 (1)| 00:00:15 | 1 | 512 |
|* 25 | TABLE ACCESS FULL | FLIGHT_SEG | 259K| 2531K| | 1175 (1)| 00:00:15 | 1 | 512 |
| 26 | PARTITION HASH ALL | | 631K| 8011K| | 1037 (1)| 00:00:13 | 1 | 512 |
|* 27 | TABLE ACCESS FULL | CUST_FLIGHT_LEG | 631K| 8011K| | 1037 (1)| 00:00:13 | 1 | 512 |
| 28 | PARTITION HASH ALL | | 239K| 25M| | 1822 (1)| 00:00:22 | 1 | 512 |
|* 29 | TABLE ACCESS FULL | CUST | 239K| 25M| | 1822 (1)| 00:00:22 | 1 | 512 |
| 30 | PARTITION HASH ALL | | 73623 | 4385K| | 243 (1)| 00:00:03 | 1 | 512 |
| 31 | TABLE ACCESS FULL | REMARK | 73623 | 4385K| | 243 (1)| 00:00:03 | 1 | 512 |
Predicate Information (identified by operation id):
2 - access("CJ"."CUST_JRNY_ID"="CJV"."CUST_JRNY_ID")
4 - filter("CJV"."VERSION_NUMBER"=0)
5 - access("FL"."CUST_JRNY_ID"="CJ"."CUST_JRNY_ID")
8 - filter(NVL("CG"."HISTORY_VERSION_NUMBER",0)=0)
9 - access("CG"."CUST_JRNY_ID"(+)="CT"."CUST_JRNY_ID")
12 - filter(NVL("RK"."HISTORY_VERSION_NUMBER",0)=0)
13 - access("CTR"."REMARK_ID"="RK"."REMARK_ID"(+))
14 - filter(NVL("CTR"."HISTORY_VERSION_NUMBER",0)=0)
15 - access("CT"."CUST_ID"="CTR"."CUST_ID"(+))
17 - access("CFL"."CUST_ID"="CT"."CUST_ID")
18 - access("FL"."FLIGHT_LEG_ID"="CFL"."FLIGHT_LEG_ID")
19 - access("FSFL"."FLIGHT_SEG_ID"="FS"."FLIGHT_SEG_ID")
20 - access("FL"."FLIGHT_LEG_ID"="FSFL"."FLIGHT_LEG_ID")
22 - filter("FL"."DEPARTURE_STATION_CODE"='DEL' AND "FL"."DEPARTURE_DATETIME"=TO_DATE(' 2012-12-10 18:45:00', 'syyyy-mm-dd
hh24:mi:ss') AND "FL"."OPR_SERVICE_PROVIDER_CODE"='AI' AND "FL"."OPR_FLIGHT_NUMBER"=1 AND "FL"."OPR_FLIGHT_SUFFIX"='A' AND
"FL"."HISTORY_VERSION_NUMBER"=0)
23 - filter("FSFL"."HISTORY_VERSION_NUMBER"=0)
25 - filter("FS"."HISTORY_VERSION_NUMBER"=0)
27 - filter("CFL"."HISTORY_VERSION_NUMBER"=0)
29 - filter("CT"."HISTORY_VERSION_NUMBER"=0) -
I'm using SQL Server 2008 R2 (10.50.4033) and I'm troubleshooting an issue that a select query against a specific view is taking more than 30 seconds consistently. The issue just starts happening this week and there is no mass changes in data.
The problem only occur if the query is issued from an IIS application but not from SSMS. One thing I noticed is that sys.dm_exec_cached_plans is returning 2 Parse Tree rows for the view - one created when the select query is issued
1st time from the IIS application and another one created when the same select query is issued 1st time from SSMS. The usecounts of the Parse Tree row for the view (the IIS one) is increasing whenever the select query is issued. The
usecounts of the Parse Tree row for the view (the SSMS one) does not increase when the select query is issued again.
There seems to be a correlation between the slowness of the query and the increasing of the usecounts of the Parse Tree row for the view.
I don't know why there is 2 Parse Tree rows for the view. There is also 2 Compiled Plan rows for the select query.
What does the Parse Tree row mean especially the usecounts column?>> The issue just starts happening this week and there is no mass changes in data.
There might be a mass changes in the execution plan for several reason without mass changes in data
If you have the old version and a way to check the old execution plan, and compare to the new one, that this should be your starting point. In most cases you don't have this option and we need to monitor from scratch.
>> The problem only occur if the query is issued from an IIS application but not from SSMS.
This mean that we know exactly what is the different and you can compare both execution plan. once you do it, you will find that they are no the same. But this is very common issue and we can know that it is a result of different SETting while connecting
from different application. SSMS is an external app like any app that you develop in Visual studio but the SSMS dose not use the Dot.Net default options.
Please check this link, to find the full explanation and solutions:
http://www.sommarskog.se/query-plan-mysteries.html
Take a look at sys.dm_exec_sessions for your ASP.Net application and for your SSMS session.
If you need more specific help, then we need more information and less stories :-)
We need to see the DDL+DML+Query and both execution plans
>> What does the Parse Tree row mean
I am not sure what you mean but the parse tree represents the logical steps necessary to execute the query that has been requested. you can check this tutorial about the execution plan: https://www.simple-talk.com/sql/performance/execution-plan-basics/ or
this one: http://www.developer.com/db/understanding-a-sql-server-query-execution-plan.html
>> regarding the usecount column or any other column check this link:
https://msdn.microsoft.com/en-us/library/ms187404.aspx?f=255&MSPPError=-2147217396.
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
Whats wrong with the sql query-- giving no rows selected
i have a table audit_data with 4 columns , eff_m & end_m are declared as timestamp and the time stamp data is different for all the records
Please advice as soon as possible as this is a production problem
ORG_GRP_I grn_n ED_EFF_m (timestamp) ED_END_M OFV
1 999 01-Jan-06 1 03-Aug-06 0 0
1 999 28-Jul-06 0 04-Aug-06 1 0
1 999 04-Aug-06 1 04-Aug-06 1 0
1 999 04-Aug-06 0 6.08
This query is giving no rows returned,even though there is data in database
SELECT NVL(OFV,0)
FROM audit_data ag
WHERE ag.ORG_GRP_I = 1
AND ag.GRN_N = 999
AND (ag.ED_EFF_M,NVL(ag.ED_END_M,SYSDATE)) IN (SELECT MAX(ED_EFF_M),MAX(NVL(ED_END_M,SYSDATE))
FROM audit_data ag2
WHERE ag2.ORG_GRP_I= ag.org_grp_i
AND ag2.grn_n=ag.grn_n
AND To_Date(To_Char(ag2.ED_EFF_M,'MM/DD/YYYY'),'MM/DD/YYYY') <= TO_DATE(TO_CHAR('08/04/06','MM/DD/YYYY'),'MM/DD/YYYY')
AND To_Date(To_Char(NVL(ag2.ED_END_M,SYSDATE),'MM/DD/YYYY'),'MM/DD/YYYY') >= TO_DATE(TO_CHAR('08/04/06','MM/DD/YYYY'),'MM/DD/YYYY'));
This query is giving value 6.08, when made type conversions.
what wrong with the above query.please advice
SELECT NVL(OFV,0)
FROM audit_data ag
WHERE ag.ORG_GRP_I = 1
AND ag.GRN_n = 999
AND (to_date(to_char(ag.ED_EFF_M,'mm/dd/yyyy'),'mm/dd/yyyy'),NVL(to_date(to_char(ag.ED_END_M,'mm/dd/yyyy'),'mm/dd/yyyy'),SYSDATE)) IN
(SELECT MAX(to_date(to_char(ED_EFF_M,'mm/dd/yyyy'),'mm/dd/yyyy')),MAX(NVL(ED_END_M,SYSDATE))
FROM audit_data ag2
WHERE ag2.ORG_GRP_I= ag.org_grp_i
AND ag2.grn_n=ag.grn_n
AND To_Date(To_Char(ag2.ED_EFF_M,'MM/DD/YYYY'),'MM/DD/YYYY') <= TO_date('08/04/2006','MM/DD/YYYY')
AND To_Date(To_Char(NVL(ag2.ED_END_M,SYSDATE),'MM/DD/YYYY'),'MM/DD/YYYY') >= TO_DATE('08/04/2006','MM/DD/YYYY'));In the second query you convert a string to a date correctly using TO_DATE(string,date format)
In the first query you try to make a char of something that already is a char, e.g. TO_CHAR('08/04/06','MM/DD/YYYY').
The TO_CHAR functions expects either a number or a date as its first parameter. That's why it's giving you a ORA-01722. -
What is the syntax for creating global temporary table using a select query
hii
I'm creating a global temporary table using a select query ..how to mention 'on commit preserve rows' that?
create global temporary table t1 as select * from trn_ordbase on commit preserve rows;
but this is invalid syntax,so how to mention on commit preserve rows in this???if i dont mention it ,by default its considering as on commit delete rows.
Please help me out of this problem.create global temporary table t1 as select * from trn_ordbase on commit preserve rows;You CANNOT use this syntax.
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/sqcmd.htm
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/glob_tab.gif
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/cre_tabl.gif -
Oracle 11g :SELECT query blocked..??
Hi Experts,
could you please explain why the below SQL query is blocked?
SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=469 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=367 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
I am scratching my head without any solution when I had a look at the db today. Thanks in advance for your help.
Regards,
Boris
Edited by: user12075620 on Dec 4, 2012 8:58 AMThe SELECT statement is not blocking the UPDATE. As I said in the previous reply, the string that this query produces does not match the logic.
This query is (at least on the surface) correctly identifying that session 1 is blocking session 2. Session 1 holds some lock that session 2 is waiting on. So far, so good. Since session 2 is waiting on the lock, we can easily enough see what session 2 is running (the UPDATE statement). But since session 1 is not blocked, it is potentially off running a ton of other SQL statements (or no SQL statement at all). The query is looking to see what session 1 is running currently. It has no way of determining what session 1 ran at some point in the past to acquire the lock in the first place.
Going back to my KING example,
At noon, session 1 runs
UPDATE emp
SET sal = sal * 2
WHERE ename = 'KING'Session 1 now has a lock on the KING row in the EMP table. But session 1 neither commits nor rolls back, it is still in a transaction. Session 1 might not have any more activity for a long time-- the user might go off to lunch, for example (obviously, applications should not be designed to allow users to maintain open transactions indefinitely, but not all applications are designed correctly). Or it might start running other queries. Let's say that session 1 now runs a query that is going to go for an hour
SELECT *
FROM giant_view_with_lots_of_computationsNow, at 12:45, session 2 comes in and runs
UPDATE emp
SET bonus = 100
WHERE ename = 'KING'Session 2 is blocked. Session 2 is running the UPDATE statement. Session 1 still holds the lock but it is running some completely unrelated SQL statement.
If we run the query you posted, the query will correctly report that session 1 is running the query against the GIANT_VIEW_WITH_LOTS_OF_COMPUTATIONS but incorrectly imply that this SELECT query is the source of the lock. It is not. It simply happens to be the query that the session that does hold the lock happens to be executing at the current moment (why the application seems to be running a lot of queries that select a constant from dual is a separate question).
Justin -
Oracle SQL Select query takes long time than expected.
Hi,
I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
The query is as follows.
select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
Kindly advice what is going wrong??
Regards,
PurushothamSQL> @/alcatel/omc1/data/query.sql
2 ;
9 rows selected.
Execution Plan
Plan hash value: 3745571015
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | SORT ORDER BY | |
| 2 | NESTED LOOPS | |
| 3 | NESTED LOOPS | |
| 4 | TABLE ACCESS FULL | PARAMETERTABLE |
|* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
|* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
|* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
|* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
Predicate Information (identified by operation id):
5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
6 - access("P1"."ID"="F1"."ID")
7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
8 - access("F1"."ID"="ID")
Note
- rule based optimizer used (consider using cbo)
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
0 bytes sent via SQL*Net to client
0 bytes received via SQL*Net from client
0 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
9 rows processed
SQL> -
Select Query resulting in Scientific Notation
Hello all,
I am running a Select query through a batch file that extracts data from an Oracle database. Several of the fields that I am extracting from contain numbers that are up to 38 digits long. When I extract the data, it converts the numbers into scientific notation and it is important for me to have the entire field. Is there something I can change to my query that will pull the data in its entire form? This is what I'm running now:
select * FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy'
I apologize in advance if this has been answered already.
Thanks!>
When the extractor finishes, it returns the data into a flat file.
don't quite understand the TO_CHAR function. Does this function mean I need to say something like this: select "TO_CHAR('column name', 99999999999999999999999999999999999999" FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy')
>
Yes- if the tool you use to extract the data (your 'extractor') is converting the numeric data to a string then it is responsible for creating the string in the proper format. If the number is an integer that can have as many digits as you have '9's in your sample format string then that is what you need to do.
Here is how sql*plus (Oracle's tool) will display the data using default settings
SQL> select 12345678901234567890123456789012345678 no_format,
2 to_char(12345678901234567890123456789012345678, '99999999999999999999999999
999999999999') with_format
3 from dual;
NO_FORMAT WITH_FORMAT
1.2346E+37 12345678901234567890123456789012345678
SQL>
----- TOAD will display something similiar but the default uses more decimal digits in the scientific notation data
NO_FORMAT,WITH_FORMAT
1.23456789012346E37, 12345678901234567890123456789012345678You can either format the numeric data in the query using TO_CHAR or the 'extractor' can do it when it converts the data to a string. -
Select query in materialized view with two dblinks
Hi All,
We have oracle 10g On windows.
We are trying to create materialized view. Scenario is we have base table on other database and we are creating mview on different database.
Basa database have two schema's and i am selecting records from that two schema's using two private db links.
But when i am tryin gto create mview its not getting created. After 15 hrs. its still showing creation command and not finished.
Query is :-
Is it good practice to have two db links in select query of materialized view.Billy Verreynne wrote:
Chanchal Wankhade wrote:
Is it good practice to have two db links in select query of materialized view.Same db link being used twice, or two different db links?
If the former, you ideally want the local Oracle db to send the join to the remote database, and for the remote database to drive the join between those 2 tables. There is a hint (<i>driving_site</i>) that can be used - or the join query can be defined on the remote database as a view, and the local materialised view can then use that remote view.
If you have 2 different db links and joining across these - usually a bad idea to perform distributed database joins. There are lots of limitations as to how the tables can be joined. Worse case, full table scans of both remote tables, pulling all the rows from the 2 remote database tables to the local database, and joining these on the local database.
I have seen some severe performance issues in the past as a result of distributed joins. I'll rather use 2 materialised views for pulling both distributed tables's data locally, and then do the join on local data (using indexes, partition pruning, etc)Hi Billy,
My scenario is i have two database database A and database B. Database A is having two schema's SCOTT AND HR. SCOTT schema have select privileges on HR schema.
DB LINK is between Database B to Database A. name is db.link.B.A.oracle.com.
What if i priovide while creating materialized view, the schema name before the table name in database B for this particuler table so it will pick up the table from that schema using same DB LINK(db.link.B.A.oracle.com.) that i am using to fetch records from SCOTT schema.
Above schnario is like two base schema's and one db link using two schema. -
Using case when statement in the select query to create physical table
Hello,
I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
I have a physical table based on a select table with one column.
SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
I also have a customer table.
In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
EXECUTION
When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
everything works as expected. YE!!
Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
FROM DUAL
Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
If anyone has any explanation to this error and how we can achieve the same, please help.
Thanks.Hello,
Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
Here is what I am trying to do. the select query of the physical table is as follows.
SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
Thanks.
Maybe you are looking for
-
Cannot Connect to the iTunes Store. Request Resource was not found
I hope you can help me. I get the following error when trying to connect to the iTunes store. iTunes could not connect to the iTunes store, the requested resource was not found. I am running Norton Internet security and have allowed all permissions f
-
WRT54GS v2.1 Firmware upgraded and wireless will not work
Hi Everyone, I have a WRT54GS v2.1 wireless g broadband router. I updated the firmware WRT54GSv3_4.71.4.001_fw.bin since that was what the linksys website said i needed. After updating the firmware on the router, my two laptops can see the router but
-
HP-UX was not able to run jvmstat2.0 (please see further details)
Good day! I would like to ask your help with JVMstat. Because for some reasons it is not working properly when I installed it on my HP-UX server. My HP-Ux has this software installed. JDK 1.4.2 Jvmstat2.0 (Unix) running on HP-UX Some Details: 1.) I h
-
How can I use a gating counter and an input counter in countinuous mode
Hi, I have a PXI 6259 with LV 7.1 and I am trying to generate a retriggerable finite pulse train (using Counter 1) in order to gate the input counter (Counter 0). For generating I found : Gen Dig Pulse Train-Finite-Retriggerable.vi that works well. F
-
How do I get my iPod Nano 6 to do a loop in a playlist?