SQL Language (MOSC)

MOSC Banner

Sub-queries does not find data some times

edited Jun 6, 2017 6:18AM in SQL Language (MOSC) 3 commentsAnswered ✓

Dear All,

I am facing a strange issue when executing below query:

SELECT COUNT(OHA.ORDER_NUMBER)

     --           INTO VORD_HEAD_CNT

                FROM OE_ORDER_HEADERS_ALL OHA

               WHERE OHA.SOURCE_DOCUMENT_ID IN

                     (SELECT PRHA.REQUISITION_HEADER_ID

                        FROM PO_REQUISITION_HEADERS_ALL PRHA

                       WHERE PRHA.Request_Id IN

                             (select Max(Request_ID)

                                FROM PO_REQUISITION_HEADERS_ALL

                               WHERE TRIM(PRHA.ATTRIBUTE15) =  TRIM(TO_CHAR(3771002))

                                 AND PRHA.AUTHORIZATION_STATUS != 'CANCELLED'));

This query returns count 0 while there is an order for that particulat id. Scenario is we are creating ISO using a program. In PO_REQUISITION_HEADERS_ALL attribute15 we are populating HEADER_ID of sales order for reference purposes. I am passing 3771002 in PO_REQUISITION_HEADERS_ALL table and getting max request id for that HEADER ID. That max request id is passed to upper query to get REQUISITION_HEADER_ID which is again passed to upper query to get sales order count. In this particular case I am not getting any count however sales order is there. Also in some cases this query works fine. I

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center