Error on the query

Started by Igor Korotabout 1 year ago4 messagesgeneral
Jump to latest
#1Pavel Stehule
pavel.stehule@gmail.com
In reply to: Igor Korot (#3)
Re: Error on the query

Hi

út 4. 3. 2025 v 18:30 odesílatel Igor Korot <ikorot01@gmail.com> 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 = c.relnamespace AND c.relname
= \'abcatc_x\' AND n.nspname = \'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 = 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 =
c.relnamespace AND c.relna
me = 'abcatc_x' AND n.nspname = 'public' "...

[/quote]

What am I missing?

you miss ending string separator

DO $$ .... $$;

DO $$
BEGIN
IF ... THEN
END IF;
END;
$$;

Regards

Pavel

Show quoted text

Thank you.

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Igor Korot (#3)
Re: Error on the query

On Tuesday, March 4, 2025, Igor Korot <ikorot01@gmail.com> wrote:

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

What am I missing?

“ ERROR: unterminated dollar-quoted string at or near‘

The terminator for your dollar-quoted string.

David J.

#3Igor Korot
ikorot01@gmail.com

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 = c.relnamespace AND c.relname
= \'abcatc_x\' AND n.nspname = \'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 = 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 =
c.relnamespace AND c.relna
me = 'abcatc_x' AND n.nspname = 'public' "...

[/quote]

What am I missing?

Thank you.

#4Igor Korot
ikorot01@gmail.com
In reply to: Pavel Stehule (#1)
Re: Error on the query

Hi, Pavel,

On Tue, Mar 4, 2025 at 11:36 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:

Hi

út 4. 3. 2025 v 18:30 odesílatel Igor Korot <ikorot01@gmail.com> 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 = c.relnamespace AND c.relname
= \'abcatc_x\' AND n.nspname = \'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 = 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 =
c.relnamespace AND c.relna
me = 'abcatc_x' AND n.nspname = 'public' "...

[/quote]

What am I missing?

you miss ending string separator

DO $$ .... $$;

DO $$
BEGIN
IF ... THEN
END IF;
END;
$$;

Thank you.
Works now.

Show quoted text

Regards

Pavel

Thank you.