6

is there any way to execute multiple statements (none of which will have to return anything) on Firebird? Like importing a SQL file and executing it.

I've been looking for a while and couldn't find anything for this.

zz1433
  • 3,528
  • 2
  • 28
  • 36

5 Answers5

13

Execute block is exactly for that purpose. Works in IBExpert too, a simple example :

execute block as
begin
  Update stuff; 
  Delete stuff; 
  Update stuff;
end

Comprehensive guide, with temporary variables and cycles into it: EXECUTE BLOCK

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
TPAKTOPA
  • 2,462
  • 1
  • 19
  • 26
2

You can do it from IBExpert with Script Executive (Menú Tools -> Script Executive). Be sure to connect to the DB you want to run the query's and then at the Script Executive dialog check the "Use current connection" for this to work.

1

In IBExpert you can execute multiple commands in single script via Tools->Script Executive (Ctrl+F12)

sra
  • 23,820
  • 7
  • 55
  • 89
0

Shouldn't the normal query-delimiter work? Like:

Update stuff; Delete stuff; Update stuff;
Bobby
  • 11,419
  • 5
  • 44
  • 69
  • 4
    It doesn't. So if I have let's say 2 alter statements to execute firebird complains about "Invalid token. Dynamic SQL Error. SQL error code = -104. Token unknown - line 2, column 1. alter." – zz1433 Nov 08 '09 at 22:33
  • 2
    Bobby is right, quey-delimiter is the normal separator. Only two comments: If you are using a tool like FeniSql you must execute the "execute script" command instead of "execute sql statement". Also, for procedures you must use the funny syntax "Set Term ^; .... Set Term ;^" and use ^ as delimiter inside the procedure. – DaniCE Nov 09 '09 at 09:08
  • 1
    I am using IBExpert, guess I haven't found yet where execute script is. I executed the same SQL file with FenixSQL and it worked. Bunch of thanks – zz1433 Nov 09 '09 at 09:25
  • I upvoted this answer since it bought me much time and am really curious who downvoted it for which reason. – A.B. Jul 07 '16 at 15:59
  • 2
    Its probably downvoted because its not useful. Trying to run an EXECUTE BLOCK with multiple statements only produces -104 errors and complaints about tokens. I'm not using any of those query tools - just the Firebird.Embedded and Firebird.Client nuget packages. Setting the terminator should make no difference, but it doesnt work either way. – StingyJack Jul 30 '17 at 01:02
  • 2
    I appreciate that this is several years later, however, why is this the accepted answer? Surely it should be the one given by TPAKTOPA? – James Geddes Jun 06 '19 at 12:35
0

You can do this with IBOConsole (download from www.mengoni.it). The SQL window allows you to enter a complete script with the usual ";" delimiter.