ERROR: syntax error at end of input & Database Error: invalid input syntax for type numeric: “Not reviewed”

Question: as shown in the title

Requirements:

(case state

When 0 then ‘unapproved’

When 1 then ‘approved’

When – 1 then ‘failed approval’

else state end) state_ name

State is a numeric type, which is not allowed in PgSQL. If a numeric type is changed to ‘unapproved’ and other character types, an error will be reported

Change it to

(case state

When ‘0’ then ‘unapproved’

When ‘1’ then ‘approved’

When ‘- 1’ then ‘failed’

else state end) state_ name

To solve the problem of error reporting

(case cast(state as varchar)

When ‘0’ then ‘unapproved’

When ‘1’ then ‘approved’

When ‘- 1’ then ‘failed’

else cast(state as varchar)end) state_ name

Database running successfully

The background still reports an error

After checking, the brackets in the SQL statement are not closed, and the modification is successful


Background error: syntax error at end of input

Note: the parentheses of the SQL statement are not closed

Similar Posts: