Solved

Query formation

Posted on 2012-03-11
3
267 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Cross Outer Join 4 51
Remove Hyphens in Oracle SQL 5 45
Value of 0's not appearing. 9 50
Oracle Subquery bad Join 11 43
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

758 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now