Connecting Tech Pros Worldwide Forums | Help | Site Map

Does ECHO work in SQLPLUS? If not what works?

Newbie
 
Join Date: Sep 2007
Posts: 4
#1: Sep 20 '07
This is a SQLPLUS question. How do I display what is being executed. In other words, in the listing below what command do I need to use to see if commit will be executed. As an example, can I say:

ECHO "commit begins";

is this the right syntax for SQLPLUS?

Expand|Select|Wrap|Line Numbers
  1. declare
  2. recs number     := 0;
  3. looper number := 0;
  4. i number;
  5. begin
  6. select count(*) into recs from TTRACK where call_dt <  '1940/01/01';
  7. if recs > 0 and recs > 4 then looper := recs/5;
  8. elsif recs between 0 and 4 then looper := 1;
  9. elsif recs = 0 then
  10. return;
  11. end if;
  12.  
  13. for i in 1..looper loop
  14. DELETE FROM TTRACK WHERE rownum < 5 AND CALL_DT < '1940/01/01';
  15.  
  16. commit;
  17.  
  18. end loop;
  19.  
  20. end;
/

amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#2: Sep 21 '07

re: Does ECHO work in SQLPLUS? If not what works?


Quote:

Originally Posted by areya

This is a SQLPLUS question. How do I display what is being executed. In other words, in the listing below what command do I need to use to see if commit will be executed. As an example, can I say:

ECHO "commit begins";

is this the right syntax for SQLPLUS?

*******************************************
declare
recs number := 0;
looper number := 0;
i number;
begin
select count(*) into recs from TTRACK where call_dt < '1940/01/01';
if recs > 0 and recs > 4 then looper := recs/5;
elsif recs between 0 and 4 then looper := 1;
elsif recs = 0 then
return;
end if;

for i in 1..looper loop
DELETE FROM TTRACK WHERE rownum < 5 AND CALL_DT < '1940/01/01';

commit;

end loop;

end;
/
***************************************end******** ****************

Make use of DBMS_OUTPUT.PUT_LINE in order to display any user defined message on the screen.

Before useing DBMS_OUTPUT package, you need to execute the below command:
Expand|Select|Wrap|Line Numbers
  1. SQL> SET SERVEROUTPUT ON
  2.  
Then you include the line DBMS_OUTPUT.PUT_LINE('Commit Begins') in your anonymous block
Reply