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:
- Use sqoop to store HDFS data in MySQL and report an error_ 1566707990804_ 0002 failed with state FAILED due to: Tas k failed
- [Oracle Scheduled Backup Failed] Oracle Backup manually Error: ORA-31634ORA-31664
- [Solved] A label can only be part of statement and a declaratioin is not a statement
- XMLHttpRequest status=0 (All You Should Know)
- [Solved] Oracle :value too large for column “SCHEMA”.”TABLE”.”COLUMN” (actual: 519, maximum: 500)
- [Solved] ./goland.sh Error: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
- Day 1 – meet Tornado
- ERROR StatusLogger No log4j2 configuration file found. Using default configuration
- dynamic_cast Error: source type is not polymorphic
- used in key specification without a key length