Home > other >  Why do i get missing SELECT keyword error
Why do i get missing SELECT keyword error

Time:10-28

So im just started with SQL and i have couple lines of code

INSERT All INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID)
VALUES 
('V01', 'WILSON', 'SARAH', 'DR', '6122', 'SENIOR PARTNER', '45,000', P1)
INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID)
('V02', 'MCDONALD', 'BRYAN', 'DR', '6153', 'SENIOR PARTNER', '35,000', P1)
INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID)
('V03', 'PATEL', 'JANE', 'DR', '6165', 'JUNIOR PARTNER', '29,000', P2)
INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID)
('V04', 'MCCAFFERTY', 'TREVOR', 'MR', '6166', 'JUNIOR PARTNER', '25,600', P2)
SELECT * FROM dual;

and im getting ORA-00928: missing SELECT keyword error not sure what im doing wrong

CodePudding user response:

You missed VALUES keyword in some statements, it's would be like below:

    INSERT All 
        INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID) VALUES ('V01', 'WILSON', 'SARAH', 'DR', '6122', 'SENIOR PARTNER', '45,000', P1) 
        INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID) VALUES ('V02', 'MCDONALD', 'BRYAN', 'DR', '6153', 'SENIOR PARTNER', '35,000', P1) 
        INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID) VALUES ('V03', 'PATEL', 'JANE', 'DR', '6165', 'JUNIOR PARTNER', '29,000', P2) 
        INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID) VALUES ('V04', 'MCCAFFERTY', 'TREVOR', 'MR', '6166', 'JUNIOR PARTNER', '25,600', P2) 
        SELECT * FROM dual;

CodePudding user response:

Like Farshid said you are missing Values on some of your statements, but you can also further simplify the statement by only comma separating your value list, instead of having a bunch of insert statements

INSERT INTO VET (VET_ID, SURNAME, FORENAME, TITLE, EXT_NUMBER, POSITION, SALARY, PRACTICE_ID)
VALUES 
('V01', 'WILSON', 'SARAH', 'DR', '6122', 'SENIOR PARTNER', '45,000', P1),
('V02', 'MCDONALD', 'BRYAN', 'DR', '6153', 'SENIOR PARTNER', '35,000', P1),
('V03', 'PATEL', 'JANE', 'DR', '6165', 'JUNIOR PARTNER', '29,000', P2),
('V04', 'MCCAFFERTY', 'TREVOR', 'MR', '6166', 'JUNIOR PARTNER', '25,600', P2)
SELECT * FROM dual;
  • Related