Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an PL/SQL Script that I'm trying to run from the command shell with SQLPLUS. However, whenever I go to run it, All I get back is a number and a cursor waiting for some input. When I hit enter, it just increments the number and repeats the process. Here is a dummy query that does the same thing

set serveroutput on

DECLARE
    cursor getServerTime IS
        SELECT sysdate as t  from dual;

    myTime getServerTime%ROWTYPE;
BEGIN
    open getServerTime;

    FETCH getServerTime into myTime;

    dbms_output.put_line(myTime.t);

    close getServerTime;
END;

to run this from the command shell I use: sqlplus me/myPass@myDB @"dummy.sql"

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You need to terminate your script with another line after the END; containing a '/' in the first column, thusly:

set serveroutput on

DECLARE
    cursor getServerTime IS
        SELECT sysdate as t  from dual;
    myTime getServerTime%ROWTYPE;
BEGIN
    open getServerTime;
    FETCH getServerTime into myTime;
    dbms_output.put_line(myTime.t);
    close getServerTime;
END;
/

When you create a PL/SQL block via SQL*Plus, the '/' tells SQL*Plus to run everything you've put into the buffer since the last command executed. The incrementing numbers you're getting is SQL*Plus giving you the next line number in your script - it's waiting for you to tell it you're done.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.