tags:

views:

240

answers:

1

I wish to create some views using SQL*Plus via script, but seem to hit a problem if a developer has placed a blank line mid statement. The following statement works fine in TOAD / PL/SQL developer etc, but fails in SQL*Plus. (This is usually scripted, but entering it manually gives exactly the same error)

Can anyone tell me why / how to stop it?

CREATE VIEW bob
AS
SELECT *

FROM DUAL;

With SQL*Plus output

SQL> CREATE VIEW bob
  2  AS
  3  SELECT *
  4
SQL> FROM DUAL;
SP2-0042: unknown command "FROM DUAL" - rest of line ignored.
+10  A: 

Hi Martin,

You would use the SET SQLBLANKLINES command:

SQL> SET SQLBLANKLINES on
SQL>
SQL> CREATE VIEW bob
  2  AS
  3  SELECT *
  4  
  5  FROM DUAL;

View created
Vincent Malgrat
Thanks! Was going insane!
MPritch
Wow - that's a weird trick to have to perform.
Jonathan Leffler
@Jonathan - It's certainly not the strangest hoop Oracle has made me jump through!
MPritch
+1 I've worked with Oracle and SQL Plus for nearly 2 decades, and didn't know that one!
Tony Andrews
+1, had never heard of it. It is apparently a quirk of SQL*Plus, as for example PL/SQL Developer behaves quite nicely with the OP's example.
DCookie