2

I am trying to learn PL/SQL, but I cannot run a basic script. At this point I feel there is not a syntax issue, but something basic I'm missing.

BEGIN
dbms_output.put_line('Hello world');
END

When I run it I get an error saying

Error starting at line : 1 in command -
BEGIN
dbms_output.put_line('Hello world');
END

When I run the script I get an error saying:

Error report -
ORA-06550: line 4, column 3:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

   ; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

If you know what I might be missing let me know.

Michael O'Neill
  • 946
  • 7
  • 22
Jaymes
  • 37
  • 5
  • do you create a function or storeprocedure for those begin end? – Juan Carlos Oropeza Mar 09 '18 at 18:13
  • If this is an anonymous PL/LSQL block in an SQL window of PL/SQL Developer, then Rajesh's answer below should resolve your issue. With this IDE, in stored procedure window (I.e., not an SQL window) you don't need that trailing terminator `/` but you do need the `END;`' – Michael O'Neill Mar 09 '18 at 18:31

1 Answers1

3

You just need a semicolon and "/" at the end, before you run the script.

BEGIN
dbms_output.put_line('Hello world');
END;
/

Don't forget to "set serveroutput on" to see the actual output.

Rajesh Chamarthi
  • 18,568
  • 4
  • 40
  • 67