If the below subquery finds no records it returns null and sets the action_batch_id as so. Is it possible to have the entire query fail/exit if the subquery returns no records?
UPDATE action_batch_items
SET action_batch_id = (SELECT id FROM action_batches WHERE id = '123'
AND batch_count < 1000 AND batch_size < 100000)
WHERE id = 1234567
UPDATE: Here's the structure (it's ActiveRecord)
CREATE TABLE "public"."action_batches" (
"id" int8 NOT NULL,
"action_batch_container_id" int8 NOT NULL,
"action_message" json,
"adaptor" json,
"batch_count" int4 DEFAULT 0,
"batch_size" int8 DEFAULT 0
)
CREATE TABLE "public"."action_batch_items" (
"id" int8 NOT NULL,
"action_batch_id" int8,
"config" json
)