Basic FOR loop with synbtax error

Thomas Collignon's profile image Thomas Collignon posted 2 years ago in General Permalink

I try to run a simple FOR loop but I get a syntax error at line 1.

FOR cnt IN 10..60 LOOP
    INSERT INTO recipe_ws_ultimate_log
     VALUES (cnt, 'filename-5.csv', '12015726004', 1, '0385344', NULL, NULL, '2022-10-04 07:00:00', 'false', '237708', '3506');
END LOOP;

SQL statement delimiter is set to ; as by default.

ansgar's profile image ansgar posted 2 years ago Permalink

You need to change the delimiter to something else if you use the semicolon inside your statement:

Description

Thomas Collignon's profile image Thomas Collignon posted 2 years ago Permalink

Thanks, now I have a better understanding of this delimiter. Still I use Run selection and it doesn't work:

Description

ansgar's profile image ansgar posted 2 years ago Permalink

I would say then the server does not understand your FOR syntax. Never saw that syntax for MySQL, or is it PostgreSQL?

Thomas Collignon's profile image Thomas Collignon posted 2 years ago Permalink

It is PostgreSQL

Thomas Collignon's profile image Thomas Collignon posted 2 years ago Permalink

Ok I get the same error with another tool, the syntax is in charge. Thanks for your help.

Please login to leave a reply, or register at first.