0

Having issues with an Insert Statement, can someone please assist me with my errors. I am getting error

ERROR at line 2: ORA-00933: SQL command not properly ended.

This is what I have so far, and thank you in advance.

SELECT GuestID, FirstName, LastName, Province;
FROM GUEST_JJ_9263
WHERE GuestID IS NULL OR FirstName IS NULL OR LastName IS NULL or City IS NULL OR Province IS NULL;
INSERT INTO GUEST_JJ_9263 (GuestID) VALUES (9999)
SELECT GuestID, FirstName ,LastName ,City ,Province
 FROM GUEST_JJ_9263
  WHERE GuestID IS NULL OR FirstName IS NULL OR LastName IS NULL or City IS NULL OR Province IS NULL;
ORDER BY LastName DESC, FirstName ASC;

I keep getting an error.

4
  • 3
    .. OR Province IS NULL; .. - excess ';' char, must be removed. PS. reporting about an error always provide complete error message text.
    – Akina
    Oct 25 at 8:09
  • My apologies, I am getting error "ERROR at line 2: ORA-00933: SQL command not properly ended."
    – nai
    Oct 25 at 8:16
  • 1
    Your DBMS is OracleDB, not MySQL. Nevertheless the source of your problem is the same - excess ; which must be removed.
    – Akina
    Oct 25 at 8:22

1 Answer 1

0

You actually want the semicolon at the end of the first line:

INSERT INTO GUEST_JJ_9263 (GuestID) VALUES (9999);

which will create a row in your table GUEST_JJ_9263 with GuestID column populated with 9999.

The next part will select out that row plus any others that meet the criteria.

If you are trying to duplicate the already-existing rows, you want:

INSERT INTO GUEST_JJ_9263 SELECT GuestID, FirstName, LastName, City, Province FROM GUEST_JJ_9263 WHERE GuestID IS NULL OR FirstName IS NULL OR LastName IS NULL OR City IS NULL OR Province IS NULL;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.