Solved

Query formation

Posted on 2012-03-11
3
271 Views
Last Modified: 2012-06-21
Hi,

Please check the attached function, can I bring this function and the attached query in single
Select statement.

Query file attached calling function, and it is taking so much time, any suggestions or forming this whole thing into a single query would be helpful.

Please help.

Thanks.
query.sql
function.sql
0
Comment
Question by:neoarwin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
flow01 earned 500 total points
ID: 37707747
as far as i can see most information is already in your query


try replacing
volumesituation(iv.acct_nr,iv.ord_id,iv.cmpgn_nr,iv.cmpgn_yr,iv.vol_nr) AS situacao

by

CASE
WHEN  (tkg.point_trkg_cd not in (23,30) AND  iv.devltn_drft_nr is null) THEN
   CASE
      WHEN  (select count(1)  from sir_sbmsn_acct b
               where  iv.cmpgn_nr = b.cmpgn_nr
                  AND iva.cmpgn_yr = b.cmpgn_yr
                  AND iva.acct_nr = b.acct_nr
                  AND iv.ord_id  = b.ord_id
                  AND b.SBMSN_ACCT_TYP in(4,13)) > 0) THEN 'volume não escaneado no transportador'
   ELSE  
      'volume duplicado'
   END
ELSE
   CASE  
      WHEN (tkg.point_trkg_cd in (23,30)  AND  tkg.point_trkg_cd =25) THEN 'volume não recebido no CD (trânsito)'
   ELSE
      NULL
   END
END  AS situacao
0
 

Author Comment

by:neoarwin
ID: 37712506
Thank you very much I will try this :)
0
 

Author Closing Comment

by:neoarwin
ID: 37762748
It never worked out by that way, but you did a good try and I appreciate that, thank you very much.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle create type table from existing table%rowtype ? 6 103
subtr returning incorrect value 8 101
Error 14 initializing SQL*Plus 4 22
replicate in oracle 13 45
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question