0

I hope you are well. I need your help with the following question from kaplan trianing exam question. The query below is suppose to be the correct answer but I cannot get it to work. Could you please check and advise.

rgd's

Norman

SQL> EDIT
Wrote file afiedt.buf



INSERT INTO
(SELECT PHYSICIAN_ID, LAST_NAME, FIRST_NAME, LICENSE_NO, HIRE_DATE
FROM PHYSICIAN
WITH CHECK OPTION
WHERE LICENSE_NO BETWEEN 1 AND 200)
VALUES (PHY_NUM_SEQ.NEXTVAL, '&LNAME', '&FNAME', &LNO, SYSDATE)

SQL> /
**Enter value for lname: BARRETT

Enter value for fname: NORMAN

Enter value for lno: 1**

old   6: VALUES (PHY_NUM_SEQ.NEXTVAL, '&LNAME', '&FNAME', &LNO, SYSDATE)
new   6: VALUES (PHY_NUM_SEQ.NEXTVAL, 'BARRETT', 'NORMAN', 1, SYSDATE)
WHERE LICENSE_NO BETWEEN 1 AND 200)

*

> **ERROR at line 5: ORA-00907: missing right parenthesis**



SQL> `SELECT PHY_NUM_SEQ.NEXTVAL FROM DUAL;`



   NEXTVAL
----------
         1



SQL> DESC PHYSICIAN


Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 PHYSICIAN_ID                              NOT NULL NUMBER
 LAST_NAME                                 NOT NULL VARCHAR2(30)
 FIRST_NAME                                NOT NULL VARCHAR2(25)
 LICENSE_NO                                NOT NULL NUMBER(7)
 HIRE_DATE                                          DATE


SQL>
1
  • You are not specifying a table name for the insert. It should be insert into target_table (column_1, column_2, ...) select ... from ... (no values clause!) Commented May 25, 2018 at 10:37

1 Answer 1

1

There's WITH CHECK OPTION line which causes the error

ORA-00907: missing right parenthesis

inside your SELECT statement.

It's enough to remove that line.

Sign up to request clarification or add additional context in comments.

1 Comment

Cheers guys you are correct the WITH CHECK OPTION should be below the WHERE clause. Working now

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.