Page 1 of 1

postgresql insert syntax error

Posted: Wed Aug 08, 2018 9:14 pm
by barb woolums
This is driving me nuts, can't see the problem here.

Here is my table definition
Screenshot_15.jpg
SQL

Code: Select all

INSERT INTO custwelc_section (owner, sheader, scontent) VALUES (5, 'about me', 'vvvvvvvvvvvvvvvvv');
error in phpPgAdmin

SQL error:

ERROR: syntax error at or near "INTO"
LINE 1: SELECT COUNT(*) AS total FROM (INSERT INTO custwelc_section ...
^

In statement:
SELECT COUNT(*) AS total FROM (INSERT INTO custwelc_section (owner, sheader, scontent) VALUES (5, 'about me', 'vvvvvvvvvvvvvvvvv')) AS sub

Re: postgresql insert syntax error

Posted: Wed Aug 08, 2018 10:24 pm
by Christopher
I don't think you can use an INSERT as a sub-select. Maybe try:

GET DIAGNOSTICS integer_var = ROW_COUNT;

Re: postgresql insert syntax error

Posted: Wed Aug 08, 2018 10:43 pm
by barb woolums
I didn't use it as a subselect, that's just how is is displayed in the error. All I entered was the insert statement as shown.

Re: postgresql insert syntax error

Posted: Wed Aug 08, 2018 10:55 pm
by barb woolums
It's working now, and the only thing I did was try it in pgadmin :)