K
K
KTG2019-03-17 10:58:25
Oracle
KTG, 2019-03-17 10:58:25

[SQLPLUS] How to get the number of returned rows?

I have a batch pipeline function called in SQLPLUS that writes the result (table) to a file.
I need to additionally count the number of returned rows, and if nothing is returned, then exit the script with an error code.

WHENEVER oserror exit 1;
WHENEVER sqlerror exit 2;
SET HEADING OFF
SET FEEDBACK OFF
SET PAGESIZE 0
SET ECHO OFF
SPOOL ./tmp/retTables.txt
SELECT * FROM TABLE(usr.util_pack.Get_List);
SPOOL OFF;
exit 0;

I have no idea how to count the lines, and that they would not fall into the resulting file.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question