How to improve on insert-select query performance
Hi,
Would like to get some opinion on how to improve this query inside my stored proc.
This insert stmt has run more than 4 hours for inserting around 62k records.
I have identified the bottleneck is in the function within the select stmt.
Could anyone help to finetune?
INSERT INTO STG_PRICE_OUT
( ONPN,
EFFECTIVE_DT,
PRICE_CATENAME,
QUEUE_ID
SELECT P.ONPN, P.EFFECTIVE_DT,
gps_get_catename(P.PART_STATUS ,P.PROGRAM_CD ,P.MARKET_CD),
'1'
FROM PRICE P,
GPS_INV_ITEMS GII
WHERE P.ONPN = GII.ONPN
FUNCTION Gps_Get_Catename
p_status VARCHAR2,
p_pgm VARCHAR2,
p_market VARCHAR2
RETURN VARCHAR2
IS
catename VARCHAR2(30);
BEGIN
SELECT PRICE_CATENAME
INTO catename
FROM PRICE_CATEGORY PC
WHERE NVL(PC.PART_STATUS,' ')= NVL(p_status,' ')
AND NVL(PC.PROGRAM_CD,' ') = NVL(p_pgm,' ')
AND NVL(PC.MARKET_CD,' ') = NVL(p_market,' ')
RETURN catename;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
RETURN NULL;
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('gps_get_catename: Exception caught!! (' || SQLCODE || ') : ' || SQLERRM);
RETURN catename;
END;
STG_PRICE_OUT has around 1 mil records
GPS_INV_ITEMS has around 140K records
PRICE has around 60k records
INDEX:
STG_PRICE_OUT - INDEX 1(ONPN), INDEX2(ONPN,QUEUE_ID)
GPS_INV_ITEMS - INDEX 3(ONPN)
PRICE - INDEX 4(ONPN)
PRICE_CATEGORY - INDEX 5(PART_STATUS ,PROGRAM_CD ,MARKET_CD)
Thanks and regards,
WH
Only use PL/SQL when you can't do it all in SQL...
INSERT INTO STG_PRICE_OUT
( ONPN,
EFFECTIVE_DT,
PRICE_CATENAME,
QUEUE_ID
SELECT P.ONPN, P.EFFECTIVE_DT,
PC.PRICE_CATENAME,
'1'
FROM PRICE_CATEGORY PC, PRICE P,
GPS_INV_ITEMS GII
WHERE P.ONPN = GII.ONPN
AND PC.PART_STATUS(+) = P.PART_STATUS
AND PC.PROGRAM_CD(+) = P.PROGRAM_CD
AND PC.MARKET_CD(+) = P.MARKET_CD
/Cheers, APC
P.S. You may need to tweak the outer joins - I'm not quite sure what your business rule is.
Similar Messages
-
How to improve Oracle Veridata Compair pair performance with tables that have big (30-40MB)CLOB/BLOB fileds ?
Can you use insert .. returning .. so you do not have to select the empty_clob back out.
[I have a similar problem but I do not know the primary key to select on, I am really looking for an atomic insert and fill clob mechanism, somone said you can create a clob fill it and use that in the insert, but I have not seen an example yet.] -
How to find for which select statement performance is more
hi gurus
can anyone suggest me
if we have 2 select statements than
how to find for which select statement performance is more
thanks®ards
kals.hi check this..
1 .the select statement in which the primary and secondary keys are used will gives the good performance .
2.if the select statement had select up to i row is good than the select single..
go to st05 and check the performance..
regards,
venkat -
SELECT query performance : One big table Vs many small tables
Hello,
We are using BDB 11g with SQLITE support. I have a query about 'select' query performance when we have one huge table vs. multiple small tables.
Basically in our application, we need to run select query multiple times and today we have one huge table. Do you guys think breaking them into
multiple small tables will help ?
For test purposes we tried creating multiple tables but performance of 'select' query was more or less same. Would that be because all tables will map to only one database in backed with key/value pair and when we run lookup (select query) on small table or big table it wont make difference ?
Thanks.Hello,
There is some information on this topic in the FAQ at:
http://www.oracle.com/technology/products/berkeley-db/faq/db_faq.html#9-63
If this does not address your question, please just let me know.
Thanks,
Sandra -
Select query performance improvement - Index on EDIDC table
Hi Experts,
I have a scenario where in I have to select data from the table EDIDC. The select query being used is given below.
SELECT docnum
direct
mestyp
mescod
rcvprn
sndprn
upddat
updtim
INTO CORRESPONDING FIELDS OF TABLE t_edidc
FROM edidc
FOR ALL ENTRIES IN t_error_idoc
WHERE
upddat GE gv_date1 AND
upddat LE gv_date2 AND
updtim GE p_time AND
status EQ t_error_idoc-status.
As the volume of the data is very high, our client requested to put up some index or use an existing one to improve the performance of the data selection query.
Question:
4. How do we identify the index to be used.
5. On which fields should the indexing be done to improve the performance (if available indexes donu2019t cater to our case).
6. What will be the impact on the table performance if we create a new index.
Regards ,
RaghavQuestion:
1. How do we identify the index to be used.
Generally the index is automatically selected by SAP (DB Optimizer ) ( You can still mention the index name in your select query by changing the syntax)
For your select Query the second Index will be called automatically by the Optimizer, ( Because the select query has u2018Updatu2019 , u2018uptimu2019 in the sequence before the u2018statusu2019 ) .
2. On which fields should the indexing be done to improve the performance (if available indexes donu2019t cater to our case).
(Create a new Index with MANDT and the 4 fields which are in the where clause in sequence )
3. What will be the impact on the table performance if we create a new index.
( Since the index which will be newly created is only the 4th index for the table, there shouldnu2019t be any side affects)
After creation of index , Check the change in performance of the current program and also some other programs which are having the select queries on EDIDC ( Various types of where clauses preferably ) to verify that the newly created index is not having the negative impact on the performance. Additionally, if possible , check if you can avoid into corresponding fields .
Regards ,
Seth -
Using DB Links - Improving SELECT query performance
Hi there,
I am using dblink in the following query:
I would like to improve performance of the query by using hints as per described in the link: http://www.experts-exchange.com/Database/Oracle/9.x/Q_23640348.html. However, i am not sure how can i include this in my select query.
Details are:
Oracle - 9i Database Terminal Release .8
DB Link: TCPROD
Could someone please explain with an example how to use hints to get the query to select data on the remote database and then return the results to the target database?
Many Thanks.
SELECT ec.obid AS prObid,
ec.b2ProgramName AS program,
ec.projectName AS project,
ec.wbsID AS prNo,
ec.wbsName AS title,
ec.revision AS revision,
ec.superseded AS revisionSuperseded,
ec.lifeCycleState AS lifeCycleState,
ec.b2ChangeType AS type,
ec.b2Complexity AS subType,
ec.r1SsiCode AS ssi,
ec.b2disposition as disposition,
ec.wbsOriginator AS requestor,
ec.wbsAdministrator AS administrator,
ec.changepriority as priority,
ec.r1tsc as tsc,
ec.t1comments as tenixComments,
ec.b2securityclass as securityClassification,
ec.t1changesafety as safety,
ec.t1actionofficer as actionOfficer,
ec.t1changereason as changeReason,
ec.t1wbsextchangenumber as extChangeNo,
ec.creator as creator,
to_date(substr(ec.creationdate,
0,
instr(ec.creationdate, ':', 1, 3) - 1),
'YYYY/MM/DD-HH24:MI:SS') as creationdate,
to_date(ec.originatorassigndate, 'YYYY/MM/DD') as originatorassigndate,
zbd.description as description,
zbc.comments as comments
FROM (SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM awdbt1m4.cmPrRpIt@TCPROD
UNION
SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM mart1m4.cmPrRpIt@TCPROD
UNION
SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM mpsdt1m4.cmPrRpIt@TCPROD
UNION
SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM nondt1m4.cmPrRpIt@TCPROD
UNION
SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rnast1m4.cmPrRpIt@TCPROD
UNION
SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rnlht1m4.cmPrRpIt@TCPROD
UNION
SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rnolt1m4.cmPrRpIt@TCPROD
UNION
SELECT obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rzptt1m4.cmPrRpIt@TCPRODit's the tablename in the hint, not the column name
something like
SELECT ec.obid AS prObid,
ec.b2ProgramName AS program,
ec.projectName AS project,
ec.wbsID AS prNo,
ec.wbsName AS title,
ec.revision AS revision,
ec.superseded AS revisionSuperseded,
ec.lifeCycleState AS lifeCycleState,
ec.b2ChangeType AS type,
ec.b2Complexity AS subType,
ec.r1SsiCode AS ssi,
ec.b2disposition as disposition,
ec.wbsOriginator AS requestor,
ec.wbsAdministrator AS administrator,
ec.changepriority as priority,
ec.r1tsc as tsc,
ec.t1comments as tenixComments,
ec.b2securityclass as securityClassification,
ec.t1changesafety as safety,
ec.t1actionofficer as actionOfficer,
ec.t1changereason as changeReason,
ec.t1wbsextchangenumber as extChangeNo,
ec.creator as creator,
to_date(substr(ec.creationdate,
0,
instr(ec.creationdate, ':', 1, 3) - 1),
'YYYY/MM/DD-HH24:MI:SS') as creationdate,
to_date(ec.originatorassigndate, 'YYYY/MM/DD') as originatorassigndate
FROM (SELECT /*+ DRIVING_SITE(awdbt1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM awdbt1m4.cmPrRpIt@TCPROD
UNION
SELECT /*+ DRIVING_SITE(mart1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM mart1m4.cmPrRpIt@TCPROD
UNION
SELECT /*+ DRIVING_SITE(mpsdt1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM mpsdt1m4.cmPrRpIt@TCPROD
UNION
SELECT /*+ DRIVING_SITE(nondt1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM nondt1m4.cmPrRpIt@TCPROD
UNION
SELECT /*+ DRIVING_SITE(rnast1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rnast1m4.cmPrRpIt@TCPROD
UNION
SELECT /*+ DRIVING_SITE(rnlht1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rnlht1m4.cmPrRpIt@TCPROD
UNION
SELECT /*+ DRIVING_SITE(rnolt1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rnolt1m4.cmPrRpIt@TCPROD
UNION
SELECT /*+ DRIVING_SITE(rzptt1m4.cmPrRpIt) */ obid,
b2ProgramName,
projectName,
wbsID,
wbsName,
revision,
superseded,
lifeCycleState,
b2ChangeType,
b2Complexity,
r1SsiCode,
b2disposition,
wbsOriginator,
wbsAdministrator,
changepriority,
r1tsc,
t1comments,
b2securityclass,
t1changesafety,
t1actionofficer,
t1changereason,
t1wbsextchangenumber,
creator,
creationdate,
originatorassigndate
FROM rzptt1m4.cmPrRpIt@TCPROD) ec(not tested, of course) -
How to put loop in select query..?
Hi All,
I am setting select query which CRecordSet is going to execute.
Existing query is,
Select branchNumber,Count(*) from branches where branchNumber = %d and dowloadType >%d;
Here %d is getting filled every time with new value. Now this query is getting execute 500 times if 500 branches are there.
We want to improve performance. and want branchnumber and count(*) in One go.
something like,
select branchNumber,Count(*) from Branches where
(branch =1 and dowloadType >2)
(branch =2 and dowloadType >100)
(branch =3 and dowloadType >234)
how can we do that?
Kindly help me on this.
Thanks,
Sachin.Thanks For reply. but here values are coming from different collection from source code.
For e.g. Map[branchNumber][DownloadType] = [1,233],[2,444],[30,234],[5,456].
Now these values i need to insert at the place of S.branch and S.DownloadType
SELECT GB.Branch ,
COUNT(*)
FROM @Sample S
INNER JOIN @GroupBy GB ON GB.Branch = (value from map)
AND GB.DownloadType < (value from map)
GROUP BY GB.Branch; -
How to Improve perfomance of this query
Hi,
Please help me to improve this query performance. Objective of this query is to find out individual count who order the product in last two year and create a matrix with time period
Challenge is Both the table having more than 600 million record so it is taking to much time to execute
SELECT count(unique b.individual_id),
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 45 THEN 1 ELSE 0 END )) AS one_month ,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 105 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 45 THEN 1 ELSE 0 END )) AS Three_month,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 195 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 105 THEN 1 ELSE 0 END )) AS six_month,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 380 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 195 THEN 1 ELSE 0 END )) AS one_year,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 745 and NVL(ORDER_DT,TO_DATE('05-MAY-1955'))<= SYSDATE - 380 THEN 1 ELSE 0 END )) AS two_year
from ORDER b, address a
where b.individual_id = a.individual_id
and a.COUNTRY_CD ='US'
group by a.COUNTRY_CD ;
Thanks
Neeraj
Edited by: user4522368 on Aug 17, 2010 12:10 AMuser4522368 wrote:
Hi,
Please help me to improve this query performance. Objective of this query is to find out individual count who order the product in last two year and create a matrix with time period
Challenge is Both the table having more than 600 million record so it is taking to much time to execute Dombrooks has provided you with an excellent response.
In addition, you should mention how much time the query is currently taking and how much do you expect it to take, what is your database version etc.
One of the most important thing is to post your SQLs and EXPLAIN PLAN outcomes in readable format. You can do this by wrapping it within \ and \ tags.
Now, based on the limited details that you have provided, following are my questions/observations:
a) You claim that both tables have more than 600 million rows but your plan shows that optimizer is expecting to find only 46 million rows in ORDER table. You may want to confirm if statistics on both the tables are correct.
b) Your plan appears to suggest that the UNIQUE is not affecting the query results. Based on your knowledge of your data, do you need the COUNT(UNIQUE individual_id) or can it be just COUNT(individual_id)?
c) Finally, if you are interested in only last two years of data, you should probably have a WHERE predicate on your ORDER table which filters data based on ORDER_DT. Something like following:
SELECT count(unique b.individual_id),
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 45 THEN 1 ELSE 0 END )) AS one_month ,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955'))>= SYSDATE - 105 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 45 THEN 1 ELSE 0 END )) AS Three_month,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 195 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 105 THEN 1 ELSE 0 END )) AS six_month,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 380 and NVL(ORDER_DT,TO_DATE('05-MAY-1955')) <= SYSDATE - 195 THEN 1 ELSE 0 END )) AS one_year,
sum((CASE WHEN NVL(ORDER_DT,TO_DATE('05-MAY-1955')) >= SYSDATE - 745 and NVL(ORDER_DT,TO_DATE('05-MAY-1955'))<= SYSDATE - 380 THEN 1 ELSE 0 END )) AS two_year
from ORDER b, address a
where b.individual_id = a.individual_id
and a.COUNTRY_CD ='US'
and b.ORDER_DT <= (SYSDATE - 380)
group by a.COUNTRY_CD ; -
SELECT query performance issue
Hello experts!!!
I am facing the performance issue in the below SELECT query. Its taking long time to execute this query.
Please suggest how can i improve the performance of this query.
SELECT MBLNR MATNR LIFNR MENGE WERKS BUKRS LGORT BWART INTO CORRESPONDING FIELDS OF TABLE IT_MSEG
FROM MSEG
WHERE MATNR IN S_MATNR
AND LIFNR IN S_LIFNR
AND WERKS IN S_WERKS
AND BUKRS IN S_BUKRS
AND XAUTO = ''
AND BWART IN ('541' , '542' , '543' , '544', '105' , '106').
Thanks in advance.
Regards
AnkurHi Ankur,
the MSEG index for material is
Index MSEG~M
MANDT
MATNR
WERKS
LGORT
BWART
SOBKZ
It could be used very efficient if you supply values for MATNR, WERKS and LGORT.
There is no index on LIFNR. IKf you want the data for specific vendor(s), you should select from EKKO first, ir has index Index EKKO~1
MANDT
LIFNR
EKORG
EKGRP
BEDAT
You can JOIN EKKO and EKBE to get the BSEG key fields GJAHR BELNR BUZEI directly.
I don't know your details but I think you can get all you need from EKKO and EKBE. You may also consider EKPO as is has a material index Index EKPO~1
MANDT
MATNR
WERKS
BSTYP
LOEKZ
ELIKZ
MATKL
Do you really need the (much bigger) MSEG?
Regards,
Clemens -
How to get result of select query from oracle in VC
Dear All ,
I have a application in oracle which insert the data in the oracle database table.
Now i want to show all the data that has been inserted into the database table in my VC application but i don't know how to handle select query in VC.
Regards
KrishanHi Goivndu
Thanks for your reply .
I know all those things.
I have created the system & alias for my backend oracle system.
I can also see all the stored procedure that are there in my oracle system.
I just want to know how to write a select query in a stored procedure .
you can insert data , Update data through oracle procedure but i don't think there is any way to get the result of select query in stored procedure .
If you know any way to do that please do let me know .
Regards
Krishan -
SELECT Query performance tunning
Hi All,
our objective is to read value from three DSO table, for that we have written three select query .
In this we have used three internal talbes.
We have written in END routine.
A model select statement for reading the Values in DSO and move statement i have given .
for 1,75000 records it is taking about 8 hours for DTP to run .
Usually they are meaning that it will take just 20 minutes.
Can anbody help on this please ??????????????????????????????
SELECT logsys
doc_num
doc_item
comp_code
/bic/gpusiteid
/bic/gpumtgrid
/bic/gpuspntyp
/bic/gpuspndid
/bic/gpuprocmt
/bic/gpubufunc
co_area
order_quan
po_unit
entry_date
/bic/gpuitmddt
/bic/gpuovpoc
currency
/bic/gpudel_in
BT8695*
costcenter
/bic/gpuordnum
/bic/gpupostxt
BT8695*
FROM (c_poadm_det)
INTO TABLE t_podetails
FOR ALL ENTRIES IN result_package
WHERE logsys EQ result_package-logsys
AND doc_num EQ result_package-doc_num
AND doc_item EQ result_package-doc_item.
LOOP AT result_package
ASSIGNING <result_fields>.
UNASSIGN <fs_podetails>.
READ TABLE t_podetails
ASSIGNING <fs_podetails>
WITH KEY logsys = <result_fields>-logsys
doc_num = <result_fields>-doc_num
doc_item = <result_fields>-doc_item.
IF sy-subrc EQ 0.
MOVE <fs_podetails>-/bic/gpusiteid TO <result_fields>-/bic/gpusiteid.
MOVE <fs_podetails>-/bic/gpumtgrid TO <result_fields>-/bic/gpumtgrid.
MOVE <fs_podetails>-/bic/gpuspntyp TO <result_fields>-/bic/gpuspntyp.
IF <result_fields>-order_quan NE ' '.
MOVE c_true TO <result_fields>-/bic/gpucount.
ENDIF.
ENDIF.Hi,
In the Read statement just use BINARY SEARCH it will improve the performance. Before putting BINARY SEARCH first the
internal table should be sort like wht field you giving the condition in read statement.
sort t_podetails by logsys doc_num doc_item."add this line
LOOP AT result_package
ASSIGNING <result_fields>.
UNASSIGN <fs_podetails>."why your giving the unassigned here it will give the dump. why because the field symbol is not assigned after the read symbol only they going to assign.
READ TABLE t_podetails
ASSIGNING <fs_podetails>
WITH KEY logsys = <result_fields>-logsys
doc_num = <result_fields>-doc_num
doc_item = <result_fields>-doc_item. " use BINARY SEARCH here
IF sy-subrc EQ 0.
MOVE <fs_podetails>-/bic/gpusiteid TO <result_fields>-/bic/gpusiteid.
MOVE <fs_podetails>-/bic/gpumtgrid TO <result_fields>-/bic/gpumtgrid.
MOVE <fs_podetails>-/bic/gpuspntyp TO <result_fields>-/bic/gpuspntyp.
IF <result_fields>-order_quan NE ' '.
MOVE c_true TO <result_fields>-/bic/gpucount.
ENDIF.
ENDIF.
Regards,
Dhina.. -
How to use offset in select query
Suppose i have data like ssonje 00000001 as a one field in database table . i have to segregate this two data. how should I do this.the first part is of 12 characters and the last is of 10 character long.
Hi Naveen,
I am again in trouble, Now the requirement were changed. I am sending you the code which i had implemented.
Now, the user enter username(ie UNAMED) and document id (ie. TEMPD) and the output should be doucment id, which has been search through database table RFDT , field SRTFD, this field contains both the username and the document id.
That means: suppose user enters UNAMED as SSONJE and TEMPD as 0000000030, then i want to fier the select query from RFDT on field SRTFD and get only the document id of that user which user enter on input field-UNAMED.
i had tried but result were not coming.
please go through the code.
data:uname type UF05A-UNAMD.
data:temp type UF05A-TEMPD.
TYPES: BEGIN OF TEITAB_RFDT,
SRTFD TYPE RFDT-SRTFD,
END OF TEITAB_RFDT.
DATA: ITAB_RFDT TYPE TABLE OF TEITAB_RFDT.
DATA: WA_RFDT TYPE TEITAB_RFDT.
DATA: STR(22) TYPE c.
SELECT-OPTIONS:UNAMED FOR uname,
TEMPD FOR TEMP.
UNAMED-option = 'CP'.
append UNAMED.
CONCATENATE UNAMED TEMPD INTO STR.
SELECT SRTFD FROM RFDT INTO CORRESPONDING FIELDS OF TABLE ITAB_RFDT WHERE SRTFD eq str.
LOOP AT ITAB_RFDT INTO WA_RFDT.
SPLIT WA_RFDT AT SPACE INTO STR1 STR2.
WRITE: / STR1,STR2.
ENDLOOP.
Please mentioned what is the way to do this.
Thanks -
How to mention index in select query?
Hi All,
If I am using fields of two diffrent secondary index in a single select query on a table how I can mention that data should be picked according to first index used in the query?
Regards
DeepakPlease search before asking basic questions.
Thread locked.
Rob -
How to ignore zero in select query
select * from EINA where EINAMATNR = <b>yyyy</b> and EINALIFNR = <b>zzzz</b>
In select query, how to ignore zero? for example, EINAMATNR = 0000000yyyy, EINALIFNR=000zzz
Maybe I can use LIKE keyword in sql query. Any other way?
Thanks.Use the following conversion routines to convert yyyy & zzzz to remove the leading zeros and then pass it to your select query.
For Matnr -> CONVERSION_EXIT_MATN1_INPUT
For LIFNR ->CONVERSION_EXIT_alpha_input.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = yyyy
IMPORTING
output = t_lifnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = zzzz
IMPORTING
output = t_matnr.
select * from EINA where EINA~MATNR = t_matnr and EINA~LIFNR = t_lifnr . -
How can we split a select query to 3 or 4 if it is fetching much records?
I am running a query like:
select * from table_name
it will be fetching 152940696 records. Now i want to fetch this result as 3 or 4 select statements. That is, in the second query I want to fetch the records from where i stopped in the first query. and similar for the 3rd i have to continue from the 2nd query. And for the 4th query i have to start from where i have stopped in the 3rd query.
when i tried with rownum we can fetch the records upto < or <= to a particular count like 100000000. But above this count i cannot fetch using rownum. Because > or >= wont work with rownum.
Is there anyother way to split the select query as i explained.
Thanks in advanceI'll assume you want to split the query up for performance reasons.
The easiest way to do this if you have the license is to use the parallel query option, which can help, hurt or do nothing. The only way to find out is to try. PQO would be best from a performance standpoint if possible, provided it will do what you need.
Failing that as has been suggested you need a logical, scalable way to divide up the queries. It has already been pointed out that the rownum solution probably will not work correctly. Also, the MINUS with ROWNUM idea has the disadvantage of having to read a lot of the same data twice, making the query run longer.
Perhaps a range would provide a way to split up the data - something like
select whatever
from table
where primary_key < 10000000;
select whatever
from table
where primary key between 10000001 and 199999999;
...
Maybe you are looking for
-
How to enable email notification in OIM 11g
Hello, I am currently working in a stock 11.1.1.3.0 environment, and am trying to enable email notifications when a user requests to be provisioned to AD. The default approver is Xelsysadm, and I have put my email address in this account's slot. Howe
-
My iMac often wants to connect to the wrong network
I live in a retirement community that has wi-fi. Their system doesn't allow devices to see each other, so I paid for regular cable Internet access and plugged in my wireless router. It's in the room with my wife's iPad and allows us to connect w
-
Help with creating a swc creation!!
I'm currently trying to create a swc library that includes pngs and a few miscellaneous classes. Note, I'm not using Flash Professional at all, only Flash Builder 4.7. I've created an AS Library project. Put my supporting classes and pngs in the so
-
Alert Mechanism Vs Email Adapter? please help!
Hi Experts, I have requirement where I have to send error info as email. The email has following characteristics: 1. Content is multi-line. 2. Data is dynamic. 3. Content has to be formated. Like header, footer and '---' lines as separaters. 4
-
I'm using LabVIEW 2010 SP1 (32-bit) and I noticed today that I cannot place my custom controls on a VI's front panel when I use the "Select a Control..." option on the "Controls" pop-up palette. I'm wondering if anyone else is having this same proble