这时 select name 是错误的, 应为group by里没有这个字段,要么加上,要么变成select min(name)
2.10、事务异常问题
异常信息
## Cause: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block ; uncategorized SQLException; SQL state [25P02]; error code [0]; ERROR: current transaction is aborted, commands ignored until end of transaction block; nested exception is org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: smallint = boolean sql SELECT xx fom xx WHEREenable = ture
错误原因: enable字段是smallint类型查询却传了一个布尔值类型
2、update更新时的转换异常信息
Cause: org.postgresql.util.PSQLException: ERROR: column "name" is of type smallint but expression is of type boolean updatefrom xx setname = falsewherename = true
DO $$ DECLARE rec RECORD; BEGIN FOR rec INSELECT table_name, column_name,data_type FROM information_schema.columns where table_schema = '要处理的模式名' AND data_type = 'timestamp with time zone' LOOP EXECUTE'ALTER TABLE ' || rec.table_name || ' ALTER COLUMN ' || rec.column_name || ' TYPE timestamp'; ENDLOOP; END $$;
-- 注意 || 号拼接的后面的字符串前面要有一个空格 DO $$ DECLARE rec RECORD; BEGIN FOR rec INSELECT table_name, column_name,data_type FROM information_schema.columns where table_schema = '要处理的模式名' AND data_type = 'timestamp without time zone' -- 修改的字段名 and column_name in ('create_time','update_time') LOOP EXECUTE'ALTER TABLE ' || rec.table_name || ' ALTER COLUMN ' || rec.column_name || ' SET DEFAULT CURRENT_TIMESTAMP;'; ENDLOOP; END $$;