0

Facing issue while executing dynamic insert query in postgresql

query used in function.

EXECUTE 'INSERT INTO tblename_' ||  NEW.id|| ' VALUES ($1)' USING NEW.* ;

While executing the above line it throws this error

ERROR: query "SELECT NEW.*" returned 14 columns

1
  • What are you trying to achieve with this statement? Commented Dec 21, 2017 at 7:38

1 Answer 1

1

I think You do not need the keyword "VALUES", as you are not specifying few selected columns. You can directly use it something like this

EXECUTE 'INSERT INTO tblename_' ||  NEW.id|| ' SELECT ($1).*'
USING NEW;
Sign up to request clarification or add additional context in comments.

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.