1

So, I am getting an error on Oracle Apex which says 'ORA-00933: SQL command not properly ended' . As far as I can see there is no syntax errors within my command, if I am missing something and somebody could help me out that would be great.

My command to create the table:

CREATE TABLE details
(
    ssn INTEGER NOT NULL,
    gender VARCHAR(255),
    hair VARCHAR(255)
);

My command to add rows to the table :

INSERT INTO details(ssn, gender, hair) 
VALUES 
    (112, 'male', 'blonde'), 
    (132, 'female', 'blonde'),
    (882, 'male', 'brown'), 
    (542, 'female', 'black'), 
    (662, 'male', 'red') ;
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    As a side observation, you should be using VARCHAR2 instead of VARCHAR, which oracle recognizes only for backward compatibility. Also -- does it really take 255 characters to indicate gender? One would do it ('M' or 'F'). And 255 for hair color? You may think it doesn't matter because only the actual length of data will be stored. But this ignores that any queries will have to pre-allocate memory for the max possible size. And in some situations this will lead to out of memory errors. – EdStevens Sep 26 '21 at 17:48
  • 1
    Does this answer your question? [Oracle SQL Language Reference: INSERT](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/INSERT.html) – William Robertson Sep 26 '21 at 19:12

2 Answers2

3

As far as I can see there is no syntax errors within my command

Actually, there is. Syntax you used is invalid, as far as Oracle is concerned.


'SQL commands' on Oracle Apex, which expects only one command at a time

Actually, no. You can run several of them, just not as SQL but PL/SQL which means that you have to enclose them into BEGIN-END block. Have a look at the screenshot:

Note, however, that not everything can be run that way. DDL would, for example, require dynamic SQL.

Littlefoot
  • 131,892
  • 15
  • 35
  • 57
1

Turns out I was using 'SQL commands' on Oracle Apex, which expects only one command at a time to be ran, hence the command not properly ended error.

  • 3
    also it is not supported in oracle https://stackoverflow.com/questions/39576/best-way-to-do-multi-row-insert-in-oracle – OjtamOjtam Sep 26 '21 at 16:10