Missing select keyword ошибка sql

If those are supposed to be values you’re providing as substitution values, then you’re missing the values keyword:

insert into certf values (&certificate_id,&certificate_name,&certificate_content);

But you need the string values to be in quotes:

insert into certf values (&certificate_id,'&certificate_name','&certificate_content');

and you should supply the column names too:

insert into certf (certificate_id,certificate_name,certificate_content)
values (&certificate_id,'&certificate_name','&certificate_content');

With you current code the parser is seeing that first list of — possible, but actually invalid in this case — identifiers, i.e column names; because it hasn’t seen that values keyword yet. It’s treated as something like:

insert into certf (42,some_name,some_content);

And having done that, and when it still doesn’t see a values keyword or values list, it’s expecting this to be an insert ... select construct instead. You could do it that way:

insert into certf (certificate_id,certificate_name,certificate_content)
select &certificate_id,'&certificate_name','&certificate_content' from dual;

But you aren’t doing that. So it doesn’t see the select either, and it throws the error you see.

totn Oracle Error Messages


Learn the cause and how to resolve the ORA-00928 error message in Oracle.

Description

When you encounter an ORA-00928 error, the following error message will appear:

  • ORA-00928: missing SELECT keyword

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Correct the CREATE VIEW statement and re-execute it.

For example, if you had tried to create a view as follows:

CREATE VIEW sup_orders AS
  suppliers.supplier_id, orders.quantity, orders.price
  FROM suppliers
  INNER JOIN orders
  ON suppliers.supplier_id = orders.supplier_id
  WHERE suppliers.supplier_name = 'IBM';

You would receive the following error message:

Oracle PLSQL

You could correct the CREATE VIEW statement by including the SELECT keyword as follows:

CREATE VIEW sup_orders AS
  SELECT suppliers.supplier_id, orders.quantity, orders.price
  FROM suppliers
  INNER JOIN orders
  ON suppliers.supplier_id = orders.supplier_id
  WHERE suppliers.supplier_name = 'IBM';

ORA-00928

ORA-00928: недостает ключевого слова SELECT

Причина:

Подзапрос SELECT должен быть включен в оператор CREATE VIEW.

Действие:

Вставьте требуемое SELECT предложение после CREATE VIEW предложение, затем выполните оператор снова.

Solution 1

Without the single quotes, try

String query="insert into offer1(RCODE,OFFERNO,DAT) values(?,?,?)"; 

Solution 2

single quotes are for string literals not for identifiers only so you should remove it around the columnNames.

INSERT INTO offer1 (RCODE,OFFERNO,DAT) VALUES (?,?,?)

and use executeUpdate since you are not retrieving records which results a resultset.

from DOCS

boolean execute()

  • Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement.

ResultSet executeQuery()

  • Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.

int executeUpdate()

  • Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.

Solution 3

I was running the same issue, and in my case the query was like this:

insert into Address (number, street, id) values (?, ?, ?)

The problem was caused by the number column name since number is a reserved keyword in Oracle, and the exception was «ORA-00928: missing SELECT keyword».

So, the number column name must be escaped, like this:

insert into Address ("number", street, id) values (?, ?, ?)

and everything works fine now.

Solution 4

Please try this

String query="insert into offer1(RCODE,OFFERNO,DAT) values(?,?,?)"; 

Solution 5

Try Statement.executeUpdate instead of executeQuery.

Comments

  • I’m using the following code to insert data. But I’m receiving an error as "ORA-00928: missing SELECT keyword"

    try
    {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    java.sql.Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@xxx.xxx.x.xxx:xxxx:xxxx", "xxxx", "xxxx");
    String query="insert into offer1('RCODE','OFFERNO','DAT') values(?,?,?)"; 
        PreparedStatement ps=conn.prepareStatement(query);
        ps.setString(1,r_code);
        ps.setString(2,offerno);
        ps.setDate(3,sqlDate);
        ResultSet rs=ps.executeQuery();
        out.println("data inserted");
    }catch(Exception e)
     {
         out.println(e);
     }
    

    I can’t see any errors in this code. If someone finds, please tell me what is the mistake and how to solve it?

  • Please explain it in detail!

  • The real solution would of course be for the database to give a correct error message, this is just a workaround.

Recents

Related

ORA-00905 is a very broadly used error message, any expected keyword missing from its statement will result in ORA-00905. These are only cases we met.

ORA-00905 means that an expected keyword is missing from the statement at the specific position of statement, usually, it’s a syntax error.

In reality, this error has widely been seen in many statements if there’s any of the following problems:

  • Missing keyword
  • Misspelling keyword

SQL parser always knows what keyword should be there. If your case is neither of above problems, you may leave a comment to this post.

Let’s see some error patterns.

  1. Create Table
  2. Create Index
  3. Create View
  4. Alter Tablespace
  5. Grant Privilege

Create Table

NOT NULL

SQL> create table fruits (fruit_name varchar2(20) not, price number);
create table fruits (fruit_name varchar2(20) not, price number)
                                                *
ERROR at line 1:
ORA-00905: missing keyword

In this case, we missed NULL keyword.

SQL> create table fruits (fruit_name varchar2(20) not null, price number);

Table created.

DOUBLE PRECISION

SQL> create table fruits (fruit_name varchar2(20) not null, price double);
create table fruits (fruit_name varchar2(20) not null, price double)
                                                                   *
ERROR at line 1:
ORA-00905: missing keyword

In this case, we missed PRECISION keyword.

SQL> create table fruits (fruit_name varchar2(20) not null, price double precision);

Table created.

Create Index

SQL> create index birth_date_idx employees(birth_date);
create index birth_date_idx employees(birth_date)
                            *
ERROR at line 1:
ORA-00969: missing ON keyword

In this case, we missed ON keyword.

SQL> create index birth_date_idx on employees(birth_date);

Index created.

Create View

SQL> create view happy_employees select * from employees where salary >= 10000;
create view happy_employees select * from employees where salary >= 10000
                            *
ERROR at line 1:
ORA-00905: missing keyword

In this case, it turns out that we missed the keyword AS in the statement.

SQL> create view happy_employees as select * from employees where salary >= 10000;

View created.

Alter Tablespace

SQL> alter tablespace example add '/u01/app/oracle/oradata/ORCLCDB/ORCLPDB1/example02.dbf' size 10m autoextend on next 10m maxsize unlimited;
alter tablespace example add '/u01/app/oracle/oradata/ORCLCDB/ORCLPDB1/example01.dbf' size 10m autoextend on next 10m maxsize unlimited
                             *
ERROR at line 1:
ORA-00905: missing keyword

In this case, we missed the keyword DATAFILE in the statement.

SQL> alter tablespace example add datafile '/u01/app/oracle/oradata/ORCLCDB/ORCLPDB1/example02.dbf' size 10m autoextend on next 10m maxsize unlimited;

Tablespace altered.

Grant Privilege

SQL> grant select any table hr;
grant select any table hr
                       *
ERROR at line 1:
ORA-00905: missing keyword

In this case, we missed TO keyword.

SQL> grant select any table to hr;

Grant succeeded.

Keywords

To correctly use keywords, you can query the dynamic dictionary V$RESERVED_WORDS for sure.

Reserved Keywords

SQL> select keyword from v$reserved_words where reserved = 'Y' order by 1;

Oracle Keywords

SQL> select keyword from v$reserved_words where reserved = 'N' order by 1;

Don’t worry about the error ORA-00905 too much, it always points out the position where keyword missed. Another similar error ORA-02142 might also be thrown in ALTER TABLESPACE ADD DATAFILE statements.

  • Missing operation system как исправить ошибку
  • Missing operating system ошибка при включении компьютера
  • Missing null keyword ошибка
  • Missing model statement microcap ошибка
  • Missing media for these clips premiere pro ошибка