0

I'm running the following script to pull some results to a text table. When I run the script, it returns the script to the text file and no query results. Any idea as to why?

set feedback off
set heading off
set echo off
set define off
set linesize 500
spool \\1.1.1.1\w$\Customer_Service\Outgoing\Missing_PO_NN.txt 
select p.po
from   sv_order_check_nn p
  where  not exists (
           select 1
           from   ordusctes o
           where  o.usctes_po = p.po);
/
SPOOL OFF
2
  • 1
    It's not an answer to your question, but you really shouldn't do WHERE NOT EXISTS, its usually terrible for performance. Try doing a LEFT JOIN instead where the right table's join key is null. Commented Apr 15, 2015 at 14:57
  • I changed my query to a Left outer join. Thanks for the advice. Commented Apr 15, 2015 at 17:58

1 Answer 1

1

When I run the script, it returns the script to the text file and no query results. Any idea as to why?

Depends whether your query actually returns any rows. Did you first execute your query and check if it actually returns any rows?

select p.po
from   sv_order_check_nn p
  where  not exists (
           select 1
           from   ordusctes o
           where  o.usctes_po = p.po);
/

You are executing the query twice. You are using slash / as terminator in the end, which is going to execute whatever is in the buffer.

See this answer for similar problem and fix.

In your case, your query will be executed twice.

Sign up to request clarification or add additional context in comments.

3 Comments

If I remove the spooling scripts, it returns rows of results.
And how about trying my suggestion to remove the slash in the end?
I removed the forward slash and changed my script to a left outer join. Unfortunately, no change. Still receive the query script results as in my spooled text file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.