0

I have thousands of lines that look like this:

insert into TABLE (name) values ('name_1');
insert into TABLE (name) values ('name_2');
...
insert into TABLE (name) values ('name_10000');

Executing them one by one works just fine. But when I want to run two or more at once it will always return error at 2nd line:

Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 2, column 1.
insert.

Any clues how to fix it? Removing ; changes nothing.

resharper
  • 1
  • 1
  • have you tried using `EXECUTE BLOCK` – James Jul 19 '21 at 10:44
  • @JaimeDrq yes, and now it returns `Unexpected end of command`. But at least not at line 2, but at 146. – resharper Jul 19 '21 at 10:49
  • This means it is trying execute everything as if it is a single statement. You need to execute this as a script so IB Expert will execute the individual statement (however, I don't know IB Expert to say how to do that). Firebird itself can only execute individual statements (or statements in a PSQL block like `EXECUTE BLOCK`). – Mark Rotteveel Jul 19 '21 at 11:13
  • 1
    @MarkRotteveel solved. Need to execute these lines as script. All other ways/combinations will result in error. – resharper Jul 19 '21 at 11:18

2 Answers2

1

The syntax for EXECUTE BLOCK should be something like this:

execute block
as
begin
  insert into TABLE (name) values ('name_1');
  insert into TABLE (name) values ('name_2');
  ...
  insert into TABLE (name) values ('name_10000');
end
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
James
  • 2,954
  • 2
  • 12
  • 25
1

Execution of several SQL commands at once must be done not in the "SQL Editor" but in the "Script Executive" (Ctrl-F12 instead of F12).

user13964273
  • 1,012
  • 1
  • 4
  • 7