Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpWBZ-0070ol-CS for pgsql-general@arkaria.postgresql.org; Tue, 04 Mar 2025 17:36:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tpWBY-003OWo-11 for pgsql-general@arkaria.postgresql.org; Tue, 04 Mar 2025 17:36:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpWBX-003OWV-Ll for pgsql-general@lists.postgresql.org; Tue, 04 Mar 2025 17:36:03 +0000 Received: from mail-yb1-xb2f.google.com ([2607:f8b0:4864:20::b2f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tpWBU-000wFt-0R for pgsql-general@lists.postgresql.org; Tue, 04 Mar 2025 17:36:03 +0000 Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-e4419a47887so4429270276.0 for ; Tue, 04 Mar 2025 09:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741109760; x=1741714560; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8WJOUfIL9nwE9cGb2I5luZz3u7EUiFLwvBRX+JdzwyI=; b=A/AFTaDTWGqQOrLtE2N5zREFop/6/Z4zVlT/d55Pl2Bw/68gVfb6ljvnHlf6W3FfFv y95IsHVyzawHkFJpQDMt6i14GQkXxz1NcNuu7JR+ASWuM+eGZyj4W5SNO1Z99O8Pf0lK HV1EmbLt0DkuTfXSF6fMvtYAeOygIYE6UOFmyq9T34fx4Sna2nnBbixjpPnM+yoroUxn LotcSxzbUXzeZqRWdlKd1nAnxag2J63R3dYLNlf08r5Ev/7/KpePYfwm/6lvqZ7ff2ol VVCi9jB2G2vTzPDueyYy3k7bUJB5dAU2WwP76Gx8ukk3eEBMAjCE0O+Kgf9aeCHoib7o VMcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741109760; x=1741714560; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8WJOUfIL9nwE9cGb2I5luZz3u7EUiFLwvBRX+JdzwyI=; b=OnIKzUdDJDOYDCO4Vvsw8tZOzN6MMZQD+hxsLe1rzhx2x2x8zMYSd35WmaYrifdANG W3xxBplS2KhPuUnhoU++21S/NGNI5JqjWStReyFFbXgjwbOcDfNOGP1YKjdDC4PIK/eS lAgOEqK82Kzq1teEPUSCG14Kg8j/5CJXRpNOV3sNMt5O0QXun+p8REJZ9qLLSEWVRrWD BF4o7TiMVkMPG5f7NvmeTrsvlQKVyBP9P2yfloRzHbMnQMEv+47oSRp/mYVy4xZXY6+1 TwLBpDccuCx8U1MvjM5RbgECoOh7J5GNTGHM/Ooy5CFgUlY+QtZm0XM7QVSxytE5imW+ syVQ== X-Gm-Message-State: AOJu0YxuUIbAq5a4AZTW5CWjPj17QlZxwzlfj6lXiYlnQTo4c8Akp61y ixiVPDpLXfLcavxCdv6s2o6KS0YAd7NpRFMLhooiWNxoo3Me5ATDMZJiRH1RA/vtXc0vRWIM6KA iXC3x2gli/1fC8v4thGKhlH8k8AQ= X-Gm-Gg: ASbGnctP9muxzPpLBYOeDMq9e+IZoYVzLqyJ3N3WO+v3pfsZpbTlrcuVvE96XilRIlp bbmbB4Sx7ZTIAA7fz6iOL/9Wkx/RDdOitOBmsnritxOCn21rfMzGJTdyR5EYNm2EgfJfRHQNhyl lpf55SlulCB23mgL/BafxN10VOhZwjqsuDwSuAledu4dIAS11SxO7Xs7YBtpM= X-Google-Smtp-Source: AGHT+IEmAcIZ76E+gi+wqNDT4i3cmOo12YKikwTeIqKeAs1PKLodCabvSif17fhBbrsLCYX2RxiyBNuBh+10Ge+KzZE= X-Received: by 2002:a05:6902:230c:b0:e5a:e604:78df with SMTP id 3f1490d57ef6-e611e19cd94mr24772276.17.1741109759794; Tue, 04 Mar 2025 09:35:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Stehule Date: Tue, 4 Mar 2025 18:35:23 +0100 X-Gm-Features: AQ5f1JrnAJLRWGUJjuvS9VTNhMROWE3arkFwGET-PVRfOdEMZoBejyoDUrFy3Vo Message-ID: Subject: Re: Error on the query To: Igor Korot Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000bf69bb062f87b482" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000bf69bb062f87b482 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi =C3=BAt 4. 3. 2025 v 18:30 odes=C3=ADlatel Igor Korot = napsal: > Hi, ALL, > Trying to execute following query: > > [code] > queries.push_back( L"DO $$ BEGIN IF NOT EXISTS( SELECT 1 FROM > pg_class c, pg_namespace n WHERE n.oid =3D c.relnamespace AND c.relname > =3D \'abcatc_x\' AND n.nspname =3D \'public\' ) THEN CREATE UNIQUE INDEX > \"abcatc_x\" ON \"abcatcol\"(\"abc_tnam\" ASC, \"abc_ownr\" ASC, > \"abc_cnam\" ASC); END IF; END;" ); > [/code] > > I got: > > [quote] > $4 =3D L"ERROR: unterminated dollar-quoted string at or near \"$$ BEGIN > IF NOT EXISTS( SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid =3D > c.relnamespace AND c.relna > me =3D 'abcatc_x' AND n.nspname =3D 'public' "... > > [/quote] > > What am I missing? > you miss ending string separator DO $$ .... $$; DO $$ BEGIN IF ... THEN END IF; END; $$; Regards Pavel > > Thank you. > > > --000000000000bf69bb062f87b482 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

=C3=BAt 4. 3. 202= 5 v=C2=A018:30 odes=C3=ADlatel Igor Korot <ikorot01@gmail.com> napsal:
Hi, ALL,
Trying to execute following query:

[code]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 queries.push_back( L"DO $$ BEGIN IF NOT EX= ISTS( SELECT 1 FROM
pg_class c, pg_namespace n WHERE n.oid =3D c.relnamespace AND c.relname
=3D \'abcatc_x\' AND n.nspname =3D \'public\' ) THEN CREATE= UNIQUE INDEX
\"abcatc_x\" ON \"abcatcol\"(\"abc_tnam\" ASC= , \"abc_ownr\" ASC,
\"abc_cnam\" ASC); END IF; END;" );
[/code]

I got:

[quote]
$4 =3D L"ERROR:=C2=A0 unterminated dollar-quoted string at or near \&q= uot;$$ BEGIN
IF NOT EXISTS( SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid =3D
c.relnamespace AND c.relna
me =3D 'abcatc_x' AND n.nspname =3D 'public' "...

[/quote]

What am I missing?


you m= iss ending string separator

DO $$ .... $$;

DO $$
BEGIN
=C2=A0 IF ... THEN
<= div>=C2=A0 END IF;
END;
$$;

Re= gards

Pavel

Thank you.


--000000000000bf69bb062f87b482--