October 27, 2024
Chicago 12, Melborne City, USA
SQL

SQL query giving error msg not enough values


-- table script
CREATE TABLE employees
( 
    EMPLOYEE_ID NUMBER(6) NOT NULL, 
    FIRST_NAME  VARCHAR2(20),
    LAST_NAME VARCHAR2(25) NOT NULL,
    SALARY NUMBER(8,2),
    HIREDATE DATE,
    DEPARTMENT_ID NUMBER(4)
);

CREATE SEQUENCE emp_seq  --Sequence creation
     START WITH 1
     INCREMENT BY 1
     NOCACHE;

Question: when I tried to run this insert query, I get an error "not enough values":

INSERT INTO employees (employee_id, last_name, hiredate)
VALUES ((SELECT emp_seq.nextval, 'Smith', SYSDATE FROM dual));

Can someone explain why?

I tried running nested select statement individually, getting desired result, but when tried both queries together I’m getting that error.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video