7

Here is my code:

SET SEARCH_PATH TO work

/* Task 1 */

INSERT INTO Category (CategoryID, Name, CategoryType)    

VALUES(1,'English','fiction');

and here is the error:

ERROR:  syntax error at or near "INSERT"
LINE 4: INSERT INTO Category (CategoryID,Name,CategoryType)
          ^
********** Error **********

ERROR: syntax error at or near "INSERT"
SQL state: 42601
Character: 45
3
  • The statement is valid. Which tool are you using to run that? Do you maybe have another statement in the editor before that which you did not properly terminate with a ;? Commented Apr 26, 2016 at 21:19
  • 2
    The error is on lines 1, 2, or 3 of the code. Commented Apr 26, 2016 at 21:20
  • 5
    You need to end every statement with ; - including the set statement Commented Apr 26, 2016 at 21:30

2 Answers 2

7

You need a semi-colon at the end of the SET statement:

SET SEARCH_PATH TO work;
Sign up to request clarification or add additional context in comments.

Comments

3

Try to just do an insert into that is schema qualified:

INSERT INTO work.Category (CategoryID, Name, CategoryType)    

VALUES(1,'English','fiction');

Or

SET SEARCH_PATH TO work;

/* Task 1 */

INSERT INTO Category (CategoryID, Name, CategoryType)    

VALUES(1,'English','fiction');

Either should fix the error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.