Simple Select query but not arriving at results!
Hello All,
I have a table with primary key (antrag_nr, beladeflag, stempel)
Desc test88
Name Null? Type
ANTRAG_NR NOT NULL NUMBER
A_PROZESS NUMBER
STEMPEL NOT NULL DATE
BELADEFLAG NOT NULL VARCHAR2(1)
desc test99
Name Null? Type
ANTRAG_NR NOT NULL NUMBER
A_PROZESS NUMBER
STEMPEL NOT NULL DATE
BELADEFLAG NOT NULL VARCHAR2(1)
select * from test99;
ANTRAG_NR A_PROZESS STEMPEL B
2 4 05-JAN-05 m
1 6 07-JAN-05 m
1 7 08-JAN-05 m
1 8 09-JAN-05 m
2 5 06-JAN-05 m
select * from test88;
ANTRAG_NR A_PROZESS STEMPEL B
1 1 01-JAN-05 m
1 2 02-JAN-05 m
1 2 03-JAN-05 m
1 3 04-JAN-05 m
2 1 01-JAN-05 m
2 2 02-JAN-05 m
2 3 04-JAN-05 m
1 4 05-JAN-05 m
1 5 06-JAN-05 m
1 6 07-JAN-05 m
2 4 05-JAN-05 m
ANTRAG_NR A_PROZESS STEMPEL B
1 7 08-JAN-05 m
My query:
insert into test88
(select a.antrag_nr, a.a_prozess, a.stempel, a.beladeflag from test88 a, test99 b
where
a.antrag_nr = b.antrag_nr
and
a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
and
a.stempel = ( select max(stempel) from test88));
what the query does is:
selects the highest value for the entire stempel column in table test88 and checks the condition a.antrag_nr = b.antrag_nr &a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
but what I would like to have is
that it should check the max(stempel) for each antrag_nr in test88 & then insert.
For example when antrag_nr = 1 and then the max (stempel) in table test 88 => 08-jan-2005
Then it should check with the antrag_nr =2
and then max(stempel) in the table test88 => 05-JAN-05 and then insert the table test88 from the source table test99 & so on
according to my query it checks the highest values of stempel column 08-jan-2005 where antrag_nr=1
but it doesnt check for antrag_nr = 2 at all.
How can I arrive at such a result, Can anyone throw some insight..
Thanks in advance,
Karthik krishna.
-- Thanks to splazm for answering my previous post!
Hello All,
I have a table with primary key (antrag_nr, beladeflag, stempel)
Desc test88
Name Null? Type
ANTRAG_NR NOT NULL NUMBER
A_PROZESS NUMBER
STEMPEL NOT NULL DATE
BELADEFLAG NOT NULL VARCHAR2(1)
desc test99
Name Null? Type
ANTRAG_NR NOT NULL NUMBER
A_PROZESS NUMBER
STEMPEL NOT NULL DATE
BELADEFLAG NOT NULL VARCHAR2(1)
select * from test99;
ANTRAG_NR A_PROZESS STEMPEL B
2 4 05-JAN-05 m
1 6 07-JAN-05 m
1 7 08-JAN-05 m
1 8 09-JAN-05 m
2 5 06-JAN-05 m
select * from test88;
ANTRAG_NR A_PROZESS STEMPEL B
1 1 01-JAN-05 m
1 2 02-JAN-05 m
1 2 03-JAN-05 m
1 3 04-JAN-05 m
2 1 01-JAN-05 m
2 2 02-JAN-05 m
2 3 04-JAN-05 m
1 4 05-JAN-05 m
1 5 06-JAN-05 m
1 6 07-JAN-05 m
2 4 05-JAN-05 m
ANTRAG_NR A_PROZESS STEMPEL B
1 7 08-JAN-05 m
My query:
insert into test88
(select a.antrag_nr, a.a_prozess, a.stempel, a.beladeflag from test88 a, test99 b
where
a.antrag_nr = b.antrag_nr
and
a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
and
a.stempel = ( select max(stempel) from test88));
what the query does is:
selects the highest value for the entire stempel column in table test88 and checks the condition a.antrag_nr = b.antrag_nr &a.a_prozess not in (select a_prozess from test99 where antrag_nr = a.antrag_nr)
but what I would like to have is
that it should check the max(stempel) for each antrag_nr in test88 & then insert.
For example when antrag_nr = 1 and then the max (stempel) in table test 88 => 08-jan-2005
Then it should check with the antrag_nr =2
and then max(stempel) in the table test88 => 05-JAN-05 and then insert the table test88 from the source table test99 & so on
according to my query it checks the highest values of stempel column 08-jan-2005 where antrag_nr=1
but it doesnt check for antrag_nr = 2 at all.
How can I arrive at such a result, Can anyone throw some insight..
Thanks in advance,
Karthik krishna.
-- Thanks to splazm for answering my previous post!
Similar Messages
-
Select query is not working in BDC Program
Hi,
I am working in BDC for update valuation class for T-code mm01.Actually In this BDC i am using two recoding based on material type.
i am using two internal table : I_DATA and ITAB
Use I_DATA to hold excle data in which material No, plant , valuation type , valuation No. and ITAB for material No, material type Only.
So, i am fetching material Type ( MARA-MTART ) through select query. But Select query is not working. and also i did check MARA table according that Material Number then material no. exit in Mara Table.
Note : at run time I_DATA have 1 row but ITAB have 0 row ....
DATA: BEGIN OF I_DATA OCCURS 0,
MATNR TYPE MARA-MATNR,
WERKS TYPE MARC-WERKS,
BWTAR TYPE RMMG1-BWTAR,
VERPR TYPE BMMH1-VERPR,
BKLAS TYPE MBEW-BKLAS,
STATUS TYPE C,
END OF I_DATA.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
END OF ITAB.
Loop at I_DATA.
select matnr mtart from mara into table itab where matnr = I_DATA-matnr.
endloop.
Guide me..........If you use your
Loop at I_DATA.
select matnr mtart from mara into table itab
where matnr = I_DATA-matnr.
endloop.
At end of loop, itab will only contain the result of the last select, so use a
Loop at I_DATA.
select matnr mtart from mara APPENDING table itab
where matnr = I_DATA-matnr.
endloop.
better
if I_DATA[] is not initial.
select matnr mtart from mara into table itab
FOR ALL ENTRIES IN i_data where matnr = i_data-matnr.
endif.
Some Remarks
- If actually required (where does I_DATA come from, is it an external format, you need the internal value to use in SELECT statement), check via SE11 the correct [conversion exit|http://help.sap.com/saphelp_nw04/helpdata/en/35/26b217afab52b9e10000009b38f974/content.htm] associated with domain MATNR (Is it truly ALPHA, and not something like MATN1, so [CONVERSION_EXIT_MATN1_INPUT|http://www.sdn.sap.com/irj/scn/advancedsearch?query=conversion_exit_matn1_input])
- You could try to use BAPI like [BAPI_MATERIAL_SAVEDATA|http://www.sdn.sap.com/irj/scn/advancedsearch?query=bapi_material_savedata] and not BDC
Regards,
Raymond -
Hi Friends,
my code is :
itab-vbeln = bseg-vbeln.
if not itab-vbeln is initial.
select single vbeln inco1 inco2 into ( itab-vbeln itab-inco1 itab-inco2)
from vbrk where vbeln = itab-vbeln.
appned itab.
note : here inco1 inco2 are incoterms
my question is can we direct move the values of bseg-vbeln into itab-vbeln. ???
and i am generating the report with one varient , when i debug this report the
there is no value in bseg-vbeln. it is showing null value.thats why my select query is not working..but i want execute this select query final.
in output i want display the inco1 inco2 data.(incoterms)
any help please.
urgent.
regards,
vijay.Hi Vijay,
First you need to check it out whether <b>itab-vbeln = bseg-vbeln</b> is in with in LOOP or not (<b>if ITAB is intenal table</b>)
if itab is internal table you should write above statement with in loop, and also check it out in debug mode why bseg-vbeln value is not coming.
and one more thing you need to make small correction in ur code use ',' .
select single vbeln inco1 inco2 into ( <b>itab-vbeln, itab-inco1, itab-inco2</b>)
from vbrk where vbeln = itab-vbeln
Note: when ever use select single u should pass values into work area, dont use internal table .
<b>if you have more doubts just send your entire code then i will rewrite it.</b>
<b>Reward with points if useful.</b>
Regards,
Vijay Krishna -
A simple select query taking forever
Hi All
I am not able to execute a simple select query, I traced my session and here is TKPROF of that Trace.
Solaris 8 , Oracle 10.2.0.4.0
TKPROF: Release 10.2.0.4.0 -
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: 502_ora_28260.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
select OBJECT_ID , ORACLE_USERNAME , SESSION_ID
from
v$locked_object
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.03 32.86 0 0 6 0
total 3 0.03 32.86 0 0 6 0
Misses in library cache during parse: 1
Optimizer mode: CHOOSE
Parsing user id: SYS
Rows Row Source Operation
0 MERGE JOIN (cr=0 pr=0 pw=0 time=60 us)
0 SORT JOIN (cr=0 pr=0 pw=0 time=58 us)
0 MERGE JOIN (cr=0 pr=0 pw=0 time=42 us)
1 SORT JOIN (cr=0 pr=0 pw=0 time=2443 us)
1105 FIXED TABLE FULL X$KSUSE (cr=0 pr=0 pw=0 time=1204 us)
0 SORT JOIN (cr=0 pr=0 pw=0 time=41 us)
1001 FIXED TABLE FULL X$KTCXB (cr=0 pr=0 pw=0 time=16132 us)
0 SORT JOIN (cr=0 pr=0 pw=0 time=0 us)
0 FIXED TABLE FULL X$KTADM (cr=0 pr=0 pw=0 time=0 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
buffer busy waits 34 0.97 32.83
SQL*Net break/reset to client 1 0.00 0.00
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.03 32.86 0 0 6 0
total 3 0.03 32.86 0 0 6 0
Misses in library cache during parse: 1
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 1 19.00 19.00
buffer busy waits 34 0.97 32.83
SQL*Net break/reset to client 1 0.00 0.00
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
1 user SQL statements in session.
0 internal SQL statements in session.
1 SQL statements in session.
Trace file: 502_ora_28260.trc
Trace file compatibility: 10.01.00
Sort options: default
0 session in tracefile.
1 user SQL statements in trace file.
0 internal SQL statements in trace file.
1 SQL statements in trace file.
1 unique SQL statements in trace file.
64 lines in trace file.
32 elapsed seconds in trace file. There is nothing fishy in alert logs... Please guide
ThanksThere it is TOP
$ RUMPSHAKER>top
load averages: 6.63, 7.45, 7.88; up 33+12:02:33
3631 processes: 3616 sleeping, 5 zombie, 1 stopped, 9 on cpu
CPU states: 58.6% idle, 18.2% user, 23.2% kernel, 0.0% iowait, 0.0% swap
Memory: 192G phys mem, 92G free mem, 96G swap, 96G free swap
PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND
13752 ora0005 1 19 0 4243M 4219M sleep 5:21 62.78% oracle
17758 ora0005 1 25 0 1174M 1156M cpu 1:05 37.12% oracle
17923 root 1 57 0 18M 14M sleep 689:07 13.59% ecap_monitor
20777 root 12 58 0 14M 13M sleep 864:33 11.55% OracleAgent
18884 ora0004 1 1 0 830M 813M sleep 0:01 9.54% oracle
12070 ora0004 61 58 0 320M 315M sleep 28.5H 8.29% emagent
20347 root 16 59 0 33M 25M sleep 26.0H 6.34% caiUxsA2
17949 ist0005 1 53 0 7984K 4984K cpu 0:00 3.93% top
1 root 1 59 0 2912K 1288K sleep 32.2H 3.75% init
15035 ora0001 1 46 0 32M 22M sleep 166:43 2.98% tnslsnr
5748 ora0004 11 54 0 516M 496M sleep 389:37 2.78% oracle
20567 ora0004 1 55 0 27M 22M sleep 0:00 2.69% sqlplus
6730 ora0001 1 33 0 632M 616M sleep 0:06 2.67% oracle
20557 ora0004 1 56 0 27M 23M sleep 0:00 2.53% sqlplus
5355 ora0005 1 59 0 1154M 1137M sleep 0:04 2.46% oracleand VMSTAT 2 5
$ RUMPSHAKER> vmstat 2 5
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr s0 s1 s2 sd in sy cs us sy id
6 8 0 143125576 74272080 4628 24012 488 150 149 0 0 4 4 -2 0 25037 192698 65249 38 26 36
1 3 0 162803992 95246464 1989 6989 0 4 4 0 0 6 6 0 0 9170 57822 26434 8 13 79
1 7 0 162801352 95240296 3043 15633 4 9737 9682 0 0 0 0 0 0 11277 73516 38200 16 16 68
3 10 0 162801560 95227920 3326 12729 16 16862 16774 0 0 1 1 0 0 11377 86054 44758 16 17 68
1 10 0 162784520 95186488 9638 48359 24 11682 11626 0 0 13 13 0 0 13484 149366 44205 23 29 47 -
Why select query is not working?
CREATE OR REPLACE TYPE prod_type AS OBJECT (
pid INT,
pprice NUMBER,
MEMBER PROCEDURE display(pid IN NUMBER));
create table prod of prod_type (pid primary key);
CREATE OR REPLACE TYPE deal_type UNDER prod_type (
ctr NUMBER,
OVERRIDING MEMBER PROCEDURE display (pid IN NUMBER),
insert into prod values(deal_type(101, 4, 1));
insert into prod values(deal_type(102, 5, 0));
------below given select query is NOT WORKING ---------
select ctr from prod p where p.pid=101;
Thanks,
-Nid------below given select query is NOT WORKINGWondering how you inserted data ...
SQL> CREATE OR REPLACE TYPE prod_type AS OBJECT (
2 pid INT,
3 pprice NUMBER,
4 MEMBER PROCEDURE display(pid IN NUMBER));
5 /
Type created.
SQL>
SQL> create table prod of prod_type (pid primary key);
Table created.
SQL>
SQL> CREATE OR REPLACE TYPE deal_type UNDER prod_type (
2 ctr NUMBER,
3 OVERRIDING MEMBER PROCEDURE display (pid IN NUMBER),
4 );
5 /
Warning: Type created with compilation errors.
SQL> sho err
Errors for TYPE DEAL_TYPE:
LINE/COL ERROR
4/1 PLS-00103: Encountered the symbol ")" when expecting one of the
following:
, not pragma <an identifier>
<a double-quoted delimited-identifier> final instantiable
current order overriding static member constructor map
SQL> CREATE OR REPLACE TYPE deal_type UNDER prod_type (
2 ctr NUMBER,
3 OVERRIDING MEMBER PROCEDURE display (pid IN NUMBER));
4 /
Warning: Type created with compilation errors.
SQL> sho err
Errors for TYPE DEAL_TYPE:
LINE/COL ERROR
1/1 PLS-00590: attempting to create a subtype UNDER a FINAL type
SQL>You made an attempt to create a subtype UNDER a FINAL type - that the reason why can not work ...
Avoid deriving a subtype from this FINAL type.
HTH -
Email confirmation is required, but not arriving.
I can not log on to iTunes. Email confirmation is required, but not arriving. The email address is correct. Same problem with appleid.apple.com.
Sorry for my english ,
you have to go to all the accont of apple , like --- mac.com , me.com & the icould ,
In this accont you have to delete the prime mail ( accont of itune ) , so if you have a mac.com accont look if your email of itune is there then delete im the procedure to icloud , after go to your accont of itune valide your mail accont ( itune ) then this is going to work .
Sorry again for english .... french
good luke . -
When I hit the attach icon in mail I can select folders but not individual files
When I hit the attach icon in mail I can select folders but not individual files
Hmm....
It all smells like third party software conflict. Can you think of any candidates for third party stuff that interacts with mail, attachments, the file system? -
Hi Friends,
The below given select statement is executing successfully in version
select * from v$version;
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
but NOT in version
select * from v$version;
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
PL/SQL Release 10.2.0.2.0 - Production
"CORE 10.2.0.2.0 Production"
TNS for Solaris: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
the error message is :
ORA-00904:"SSRP"."RESOURCE_ID" invalid identifier
Error at Line 12 : Column 40
SELECT SR.RESOURCE_NAME,
SRG.RESOURCE_GROUP_NAME,
MAX(NVL((SELECT NVL(CHECKED, UNCHECKED)
FROM
(SELECT 2 AS UNCHECKED,
(SELECT 1
FROM S_USAGE_RESOURCE_PERMISSIONS SURP
WHERE SURP.USAGE_PROFILE_ID = 1
AND SURP.RESOURCE_PERMISSION_ID = SRP.RESOURCE_PERMISSION_ID) AS CHECKED
FROM S_RESOURCE_PERMISSIONS SRP
WHERE SRP.RESOURCE_PERMISSION_ID = SSRP.RESOURCE_PERMISSION_ID
AND SRP.RESOURCE_ID = SSRP.RESOURCE_ID
AND SRP.RESOURCE_PERMISSION_VAL = 4 )),0)) AS ALL_PERMISSION
FROM
S_RESOURCE_PERMISSIONS SSRP
INNER JOIN
S_RESOURCE SR ON SR.RESOURCE_ID = SSRP.RESOURCE_ID
INNER JOIN
S_RESOURCE_GROUP SRG ON SRG.RESOURCE_GROUP_ID = SR.RESOURCE_GROUP_ID
GROUP BY SR.RESOURCE_NAME, SRG.RESOURCE_GROUP_NAME;
Given SCHEMA is similar in all respects at both the databases.
can someone suggest me what could be the problem?Sorry, didn't look close enough, here a corrected query you can try to run.
If you still have problems, try to post a ddl scripts and small sample of data - this may do it easier for other to help you. When you post sql scripts, try as well to enclose them between [ pre ] [ pre ] or [ code ] [ code ] tags to increase readability.
WITH t AS (
SELECT NVL(CHECKED, UNCHECKED) NVL_CHECKED,
RESOURCE_ID,
RESOURCE_PERMISSION_ID
FROM (SELECT 2 AS UNCHECKED,
(SELECT 1
FROM S_USAGE_RESOURCE_PERMISSIONS SURP
WHERE SURP.USAGE_PROFILE_ID = 1
AND SURP.RESOURCE_PERMISSION_ID =
SRP.RESOURCE_PERMISSION_ID) AS CHECKED,
SRP.RESOURCE_ID,RESOURCE_PERMISSION_ID
FROM S_RESOURCE_PERMISSIONS SRP
WHERE SRP.RESOURCE_PERMISSION_VAL = 4))
SELECT SR.RESOURCE_NAME,
SRG.RESOURCE_GROUP_NAME,
MAX(NVL_CHECKED) AS ALL_PERMISSION
FROM S_RESOURCE_PERMISSIONS SSRP INNER_JOIN T ON (T.RESOURCE_ID =
SSRP.RESOURCE_ID AND
T.RESOURCE_PERMISSION_ID =
SSRP.RESOURCE_PERMISSION_ID)
INNER JOIN S_RESOURCE SR ON SR.RESOURCE_ID = SSRP.RESOURCE_ID
INNER JOIN S_RESOURCE_GROUP SRG ON SRG.RESOURCE_GROUP_ID =
SR.RESOURCE_GROUP_ID
GROUP BY SR.RESOURCE_NAME, SRG.RESOURCE_GROUP_NAME;Best regards
Maxim -
Simple query but not using index..please help??
I do have this column indexed. Why my query is not using this index?
Any help .
select count(*) from v_dis_sub_har;
SQL>
COUNT(*)
4543289
1 row selected.
SQL>
select vzw_vendor_id , count(*)
from v_dis_sub_har
group by vzw_vendor_id
SQL> 2 3 4
VZW_VENDOR_ID COUNT(*)
200091 908653
200013 908659
200012 908659
200057 908659
200031 908659
5 rows selected.
SQL> SQL>
explain plan for
select
event_seq
from v_dis_sub_har b
where b.VZW_VENDOR_ID='200013'
-- and b.status='P' and b.extract_date is null
SQL> 2 3 4 5 6 7
Explained.
SQL> SQL>
select plan_table_output from table(dbms_xplan.display)
SQL> SQL> 2
PLAN_TABLE_OUTPUT
Plan hash value: 2852398983
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 908K| 7986K| 3132 (16)| 00:00:38 |
|* 1 | TABLE ACCESS FULL| V_DIS_SUB_HAR | 908K| 7986K| 3132 (16)| 00:00:38 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("B"."VZW_VENDOR_ID"=200013)
13 rows selected.
SQL> SQL>You are right Justin. Oracle is not stupid as you may want to say some times when things do not happen according to you. I just created a bitmap index on status field and look what appened. Som times it uses bitmap index and some times it does not. And the reason is clear. Row count by status. 'S' status uses bitmap index where 'P' does not.
Thanks for your help.
select status, count(*)
from v_dis_sub_har
group by status
;SQL> 2 3 4
S COUNT(*)
A 5844982
P 2312759
S 20178
3 rows selected.
SQL>
explain plan for
select
event_seq
from v_dis_sub_har b
where
--b.VZW_VENDOR_ID=200013
-- and
b.status='S'
--and b.extract_date is null
select plan_table_output from table(dbms_xplan.display)
SQL> 2 3 4 5 6 7 8 9 10
Explained.
SQL> SQL> SQL> SQL> 2
PLAN_TABLE_OUTPUT
Plan hash value: 829738689
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
ime |
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 20290 | 118K| 2772 (1)| 0
0:00:34 |
| 1 | TABLE ACCESS BY INDEX ROWID | V_DIS_SUB_HAR | 20290 | 118K| 2772 (1)| 0
0:00:34 |
| 2 | BITMAP CONVERSION TO ROWIDS| | | | |
|
|* 3 | BITMAP INDEX SINGLE VALUE | V_DISPATCH_SUBSCRIPTION_NDX2 | | | |
|
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - access("B"."STATUS"='S')
15 rows selected.
SQL> SQL> set line 120
SQL> /
PLAN_TABLE_OUTPUT
Plan hash value: 829738689
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 20290 | 118K| 2772 (1)| 00:00:34 |
| 1 | TABLE ACCESS BY INDEX ROWID | V_DIS_SUB_HAR | 20290 | 118K| 2772 (1)| 00:00:34 |
| 2 | BITMAP CONVERSION TO ROWIDS| | | | | |
|* 3 | BITMAP INDEX SINGLE VALUE | V_DISPATCH_SUBSCRIPTION_NDX2 | | | | |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - access("B"."STATUS"='S')
15 rows selected.
SQL>
explain plan for
select
event_seq
from v_dis_sub_har b
where
--b.VZW_VENDOR_ID=200013
-- and
b.status='P'
--and b.extract_date is null
select plan_table_output from table(dbms_xplan.display)
SQL> 2 3 4 5 6 7 8 9 10
Explained.
SQL> SQL> SQL> SQL> 2
PLAN_TABLE_OUTPUT
Plan hash value: 2852398983
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2325K| 13M| 5784 (18)| 00:01:10 |
|* 1 | TABLE ACCESS FULL| V_DIS_SUB_HAR | 2325K| 13M| 5784 (18)| 00:01:10 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("B"."STATUS"='P')
13 rows selected.
SQL> -
Simple select query is taking a lot of time
hi gems...
my table has 7267563 rows...and i am doing a simple select * from table;
but it is taking a lot of time nearly 25minutes but not completed...
when i did select count(1) from table then it gave the result instantly also select * from table where rownum < 10 is also fine...even when i am selecting all the records using rownum i.e. select * from table where rownum < 7267563 is also giving result instantly...
but the entire table is not getting result i.e. select * from table...also there is no lock in the table(though i know that select is nothing to do with lock)..
what may be the issue..please suggest...thanks in advance...
Edited by: user12780416 on Dec 12, 2011 11:08 PMHi;
Please see below thread
query takes too long ...
help in solving long run query
HOW TO: Post a SQL statement tuning request - template posting
Hope it helps
Regard
Helios -
Select query in not working for Count(*)
Hi,
Our batch team running one query that is selecting one table TSFHEAD and this query is hanging. Below are diffrent shenario in which the select query is running on this table.
select * from tsfhead where create_id = 'BATCH' and create_date = '26-OCT-12';
--not returning any rows and hanging
select * from tsfhead where create_id = 'BATCH' ---returning rows
select * from tsfhead where create_date = '26-OCT-12'; --- returning rows
select count(*) from tsfhead ----not returning rows and hanging
This table TSFHEAD has 59000 rows.
SQL> explain plan for select * from tsfhead where create_id = 'BATCH' and create_date = '26-OCT-12';
Explained.
SQL> SELECT * FROM TABLE(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 415503093
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 67 | 215 (1)| 00:00:03 |
|* 1 | TABLE ACCESS FULL| TSFHEAD | 1 | 67 | 215 (1)| 00:00:03 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("CREATE_ID"='BATCH' AND "CREATE_DATE"='26-OCT-12')
I don't know why this query behaving in this manner.Please help.RanVijai_dba wrote:
Thanks for your reply. But +"select count(*) from tsfhead"+ is hanging and +"select * from tsfhead where create_date = '26-OCT-12' "+ is showing records.It might be showing records, but not necessarily the correct records.
As sb points out, you are treating dates as strings rather than the DATE datatype. That means you could be querying the wrong data, and your query is also not safe in different environments. It could also effect the query execution plan. Also, as pointed out, you should be ideally using 4 digit years. There were many headaches caused by the use of 2 digit years that most companies corrected as part of the millenium bug fixes prior to the year 2000... well over a decade ago, and most good designs now ensure that 4 digit years are used as standard.
So your query would be better written as:
select * from tsfhead where create_date = TO_DATE('26-OCT-2012','DD-MON-YYYY')When you say:
select count(*) from tsfhead... is hanging, you say the table has around 59000 rows in it, and in reality that's a small amount of records, so a count(*) shouldn't take long at all, even doing a full table scan.
Post the explain plan for that simple count(*) query for us. (and ensure you use {noformat}{noformat} tags to keep the formatting on the forum, as described in {message:id=9360002}) -
Using parameters in a select query sometimes not working
I use parameters throughout my code - usually without problem, but for some reason in one case it does not return a result. When I modify the querystring to contain the value instead of using parameters it works. Is it because I'm secting a clob? or is it because I'm using a 9i ODP.net dll against a 10g database? this is c# 2.0
here's the source code that does not work for me - REQUEST_DATA is a clob:
public String loadRequest(String PSRNumber)
String returnVal = null;
ConnectionStringSettings connectionInfo = System.Configuration.ConfigurationManager.ConnectionStrings["Scribe"];
OracleConnection myConnection = new OracleConnection();
String strSQL = "select PSR, REQUEST_DATA from stats.request where PSR = :PSR";
try
myConnection.ConnectionString = connectionInfo.ConnectionString;
OracleCommand cmd = new OracleCommand(strSQL, myConnection);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("PSR", OracleDbType.Varchar2).Value = PSRNumber;
myConnection.Open();
OracleDataReader dr = cmd.ExecuteReader();
if (dr.Read())
returnVal = dr.GetOracleString(dr.GetOrdinal("REQUEST_DATA")).ToString();
else
returnVal = null;
dr.Dispose();
cmd.Dispose();
catch (OracleException ex)
printError(ex.Message);
finally
myConnection.Close();
myConnection.Dispose();
return returnVal;
}when I replace the line generating the sql, and remove the lines pertaining to parameters it works:
String strSQL = String.Format("select PSR, REQUEST_DATA from stats.request where PSR = {0}", PSRNumber);
I'm fine just using this as a workaround, but I need an explanation why the other does not work - I prefer to use parameters.
Message was edited by:
user633546I figured it out. thank you for your help in pointing me in the right direction.
the problem was there was a trailing space in the data.
when the data for that table is numeric for every record, the query allows me to leave out the single quotes. Trailing spaces do not seem to cause the database to see it as non-numeric - leaving out the quote still finds the record even if there is a trailing space.
but when I put in the quote, it is not an exact string match, so it could not find the record. sometimes this flexibility gets me into trouble :\ -
Problem with SImple Select Query
Hi
I am trying to write a simple Select SQL to a table and find out whether certain data exist or not. I have done this before but now for some reason this one is not working.
I started like this
select single * from ANLH where ANLN1 = rec-Asset
and BUKRS = Comp_Cd.
* Error Handler for non-existent empno in the database
if sy-subrc = 0 or rec-asset = ''.
rec_failed = 'T'.
concatenate 'Asset does not exist' rec-asset into asst_err.
endif.
when i debugged the code i found out that sy-subrc is returning 4 all the time. (i have passes some numbers in rec-Asset which i know doesn't exist in that table.
So i have modified the code to see if its pulling anything.
like this
select single ANLN1 into v_Asset from ANLH where ANLN1 = rec-Asset
and BUKRS = Comp_Cd.
* Error Handler for non-existent empno in the database
if sy-subrc = 0 or rec-asset = ''.
rec_failed = 'T'.
concatenate 'Asset does not exist' rec-asset into asst_err.
endif.
in debug v_asset is always empty (for real number and for the madeup number)
Please help.
Thanks
Edited by: Anwarul Kabir on Apr 3, 2008 9:27 PM
Edited by: Anwarul Kabir on Apr 3, 2008 9:29 PM
Edited by: Anwarul Kabir on Apr 3, 2008 9:30 PMThanks for the answer. But i thought i was doing the same. Anyway I replaced my code with yours but result is the same. I also did this
select single
ANLN1 into v_Asset
from ANLH where
ANLN1 = '20000544'
and BUKRS = '3000'.
I did SE11 and entered the table name and i can see that data.
but on my code i get sy-subrc=4 and v_Asset is blank
again i tried with this madeup number which i know its not in the table
select single
ANLN1 into v_Asset
from ANLH where
ANLN1 = '2056555433544'
and BUKRS = '3000'.
Get sy-subrc=4 and v_Asset is blank...
Is there anything special about the Table? -
Why this query does not show the result?
Why the query with the schema prefixed does not show the result and the query without schema display the correct results?
SQL> select data_object_id,object_type from dba_objects where object_name='HR'.'JOBS';
select data_object_id,object_type from dba_objects where object_name='HR'.'JOBS'
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select data_object_id,object_type from dba_objects where object_name='HR.JOBS';
no rows selected
SQL> select data_object_id, OWNER, object_type from dba_objects where object_name='JOBS';
DATA_OBJECT_ID OWNER OBJECT_TYPE
69662 HR TABLE
OE SYNONYM
SQL> SELECT USER FROM DUAL;
USER
SYSHi,
the column object_name refers to a object_name which is 'JOBS', the column owner refers to the owner 'HR', the value isn't stored together, so you have to select the two columns. It is the same behaviour as every other table/view. Have a look at the values in the view DBA_OBJECTS.
Herald ten Dam
Superconsult.nl -
My select query in not working
hi
this my select query
select * from J_1IEXCHDR where werks = 'DT*'
this is not working
i want result where werks like DT01, DT09 and many statting with DT
so plz tel me how to write for like .
thankHi,
>
Guptaprashant wrote:
> hi
>
> this my select query
>
> select * from J_1IEXCHDR where werks = 'DT*'
>
>
> this is not working
>
> i want result where werks like DT01, DT09 and many statting with DT
> so plz tel me how to write for like .
>
> thank
Use:-
select * from J_1IEXCHDR where werks like 'DT%'.
Regards,
Tarun
Maybe you are looking for
-
'peek' Glance on my 928 doesn't work
I just recently noticed that the peek glance screen isn't working for me any longer. When I turn the screen off with the button, then the glance screen shows the time. But after a few minutes, it goes away (as expected.) If I put my hand over the pho
-
Im using a servlet that accesses a java bean within a session in order to display all the contents within the bean. The code is shown below: HttpSession session = request.getSession(); ItemBean bean = new ItemBean(); bean.setProductID(results.getStri
-
I accidently deleted a font from the font book. Luckily I don't use it. How can I get a prompt or confirmation before deleting anything. I liked to be asked "are you sure you want to do this."
-
FB, BAPI for custom PD Infotype
Hi there, i am looking for an FB or Bapi to read the Data of my own createt Infotyp. Can anyone Help btw. it is a PD Infotype! Thanks in advance Mathias
-
Does not automatically connect to wireless network anymore
Mac Book does not automatically connect to know networks any longer.