Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qHWoz-0007Le-CS for pgsql-sql@arkaria.postgresql.org; Thu, 06 Jul 2023 21:47:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qHWox-0003DI-JW for pgsql-sql@arkaria.postgresql.org; Thu, 06 Jul 2023 21:47:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qHWox-0003D9-Am for pgsql-sql@lists.postgresql.org; Thu, 06 Jul 2023 21:47:27 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qHWou-002QVi-Vs for pgsql-sql@lists.postgresql.org; Thu, 06 Jul 2023 21:47:26 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-993a37b79e2so148030366b.1 for ; Thu, 06 Jul 2023 14:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688680043; x=1691272043; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=LkIVAR7PwWoSWPEWGjJEh4d/KtEj1FjlQoEmyhMcVVc=; b=Pk0ib2735RxITy36SHaVrA/TV8kk+PwpnhQrZTfhN3NqjNfBm7j6ofLi0kjGL27Cnb Io8ld6VY+PV2wlZE1D/mu+MnP/EHRl4q6EuG+ZOH+uDtW4KLKwxr4vUdFlkECSiHRRdw jKQozTXOTsbFYYdxcFp0x3IegmTtcxdEWTX/TVrSa+Q9UK7QiI/3B7YaLjYWfUPdLHN9 8fEC3UJ2ZsbJOSv8I8pnnOD8XlsDbUl9YtsooGNgLpmV2ILpLQab+PTqOgaskwbQOQJs /r/2QGHl4lsUce3Cr0+ioSR4upJ57rd/9Tp6BJ1hUB13lpQctu+Eh6s7gc/YUWhbCh7+ KwFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688680043; x=1691272043; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LkIVAR7PwWoSWPEWGjJEh4d/KtEj1FjlQoEmyhMcVVc=; b=AI+vyVoEX9I8IjC8N4IvIIf3WYIeDC3PO8nn0d9tCPE/gAIPuaJWqSXoGvoNzKRzvy qzywvPXs1aP+d2E7WgB/w6oUhjOk1D9+M0AQr//pXnm7F4jMt9aCyv2T/yRuQDv/EHrb rZt3ND2oBo8/tltmIb1fXSwsbTl8rkwSNcbYemBLh0jvfFlazKe2ZEHzYWUDljnBisdV AW0tQWZmU8bYzb9nE7A4IKqcIQRCPI0u71aBFtWcYN5Jn5ZKvnJrkXehFqgJ+NZ9r9gA 6AqsT0uSKbGfhWN7ooaUNNUSB25Uk3ZPwQoSz+dogGRmR9azOYAf176ny+pnqJWQ+ET7 9jYw== X-Gm-Message-State: ABy/qLa3y6exJlP4FX4MI9RR9A1jaumXKCMMBRDaDbOADq61bAE1T4v1 JSIfWZhf0/bp+ALtRWp1MeAqEyDZnLEfxWbgNtSFShOWZCM= X-Google-Smtp-Source: APBJJlHqCTBZ4+0sP82daTIn7Fl/zKApPkd1/bHZ5v7r7SkoQkzLfQGIKsjqQW2Oi7J9XAU/gd4JgC3hp5LXD2AAFOc= X-Received: by 2002:a17:906:7a14:b0:98e:473c:80c4 with SMTP id d20-20020a1709067a1400b0098e473c80c4mr2611597ejo.1.1688680043200; Thu, 06 Jul 2023 14:47:23 -0700 (PDT) MIME-Version: 1.0 From: Shaozhong SHI Date: Thu, 6 Jul 2023 22:47:12 +0100 Message-ID: Subject: How do Exception, do nothing and carry on To: pgsql-sql Content-Type: multipart/alternative; boundary="0000000000001d467905ffd87621" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000001d467905ffd87621 Content-Type: text/plain; charset="UTF-8" The function in the following block code may fail. How to make it to carry on by ignoring exception? Something like Python's try catch. for i in (select distinct id from id_table) loop raise notice '%', i; insert into my_table(id, last, arr, count) SELECT i, * from my_function(i) f(last int, arr int[], count int); commit; end loop; --0000000000001d467905ffd87621 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The function in the following block = code may fail.

How to make it to carry on by ignor= ing exception?

Something like Python's try cat= ch.

for i in (select distinct id from id_table)=C2= =A0
=C2=A0 loop
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0raise= notice '%', i;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0insert into my_ta= ble(id, last, arr, count) SELECT i, * from my_function(i) f(last int, arr i= nt[], count int);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0commit= ;

=C2=A0 end loop;
--0000000000001d467905ffd87621--