我明白了
ERROR: column reference "attempt" is ambiguous LINE 101: DO UPDATE SET attempt = attempt + 1;
我正在尝试自动增加列尝试次数。插入不支持Alias,但我不确定这里出了什么问题。
INSERT INTO public.error_message(
id, created_by, created_dt, modified_by, modified_dt, attempt, message_headers, message_main_topic, message_payload, message_status, message_status_code)
VALUES (51, null, null, null, null, 1, '{
"jsonContent": {
"content-length": "1635",
"message_status_code": "417",
"cookie": "JSESSIONID=279AF4C174E6192BDAB11A067768BBD5",
"postman-token": "f0f33e86-498f-452a-aaf6-18eb84dc5907",
"kafka_timestampType": "CREATE_TIME",
"message_id": "21",
"kafka_receivedMessageKey": "null",
"kafka_receivedTopic": "error-topic",
"accept": "*/*",
"kafka_offset": "33",
"kafka_consumer": "org.apache.kafka.clients.consumer.KafkaConsumer@5091bb5f",
"host": "localhost:8082",
"content-type": "application/json",
"connection": "keep-alive",
"cache-control": "no-cache",
"kafka_receivedPartitionId": "0",
"kafka_receivedTimestamp": "1552305428711",
"accept-encoding": "gzip, deflate",
"message_main_topic": "ldarsQCustomStatistics.1",
"user-agent": "PostmanRuntime/7.6.1"
}
}', ‘abcd.1’, '{
"jsonContent": {
"messageTime": 16772223422,
"messageRev": 9,
"businessId": "DB",
"messageId": "55",
"deviceId": "DB_1234_SMM",
"assetType": "Locomotive",
"messageType": "thirdparty-timeseries",
"assetId": "DB_1234",
"appId": "ThirdPartyApp",
}
}', 1, 201)
ON CONFLICT ((message_payload->'jsonContent'->>'message_id'))
DO UPDATE SET attempt=attempt+1
答案 0 :(得分:1)
为避免原始表行与排除的插入行之间存在歧义,请限定UPDATE
:
DO UPDATE SET attempt = error_message.attempt + 1