1

I have a problem running my PL/SQL script in SQL*Plus. I can run SQL commands normally but when I want to a run any PL/SQL code it gives nothing. See code and output below.

screenshot

DECLARE
    x_salary employee.salary%TYPE;
BEGIN
    select salary
    into x_salary
    from employee
    where ssn=&enter_ssn;

    --Output the result
    DBMS_OUTPUT.PUT_LINE('Salary is ' || x_salary);

EXCEPTION
    --Output when no records are returned
    WHEN no_data_found THEN
        DBMS_OUTPUT.PUT_LINE ('No employee found');

    WHEN others THEN
        DBMS_OUTPUT.PUT_LINE ('Error encountered, but cause unknown');
END;
8
  • put a slash after semi-colon Commented Apr 12, 2020 at 21:13
  • after END ? or in the commande line? Commented Apr 12, 2020 at 21:13
  • in the command line. Commented Apr 12, 2020 at 21:14
  • @BarbarosÖzhan - what do you mean by "in the command line"? The OP said this is a script - which means he is not running it interactively. The slash should come after END; on a new line, by itself. Commented Apr 12, 2020 at 21:17
  • 1
    @BarbarosÖzhan - ah, lol - no, I usually don't open images. But even so, the backslash rather belongs in the script, not after it... (I do see your point though.) Commented Apr 12, 2020 at 21:22

2 Answers 2

6

PL/SQL procedures needs / after procedure definition under sqlplus

DECLARE
 ...
BEGIN
 ...
END;

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

1 Comment

If this answer is helpful for you, please consider to mark it as answer. Thanks
2

Put a slash / in a new line after END; in your script.

From the documentation:

You must include a semicolon at the end of each SQL command and a slash (/) on a line by itself after each PL/SQL block in the file.

Then execute the SQL file in SQL*Plus command line as:

@C:\your_script.sql;

Comments

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.