Insert various data into ibexpert

Asked

Viewed 4,170 times

1

Good guys a little while ago I started using the Firebird and I have the following problem , when trying to insert some data directly in the IB Expert it returns me the following error :

Invalid token. Dynamic SQL Error. SQL error code = -104. Token Unknown - line 4, column 1. (.

I am trying to insert as follows :

INSERT INTO CIDADE (CODIGO,NOME,ESTADO) VALUES

(1, 'Afonso Cláudio', 8);
(2, 'Água Doce do Norte', 8);
(3, 'Águia Branca', 8);
(4, 'Alegre', 8);
(5, 'Alfredo Chaves', 8);
(6, 'Alto Rio Novo', 8);
(7, 'Anchieta', 8);
(8, 'Apiacá', 8);
(9, 'Aracruz', 8);
(10, 'Atilio Vivacqua', 8); ...

it gets kind of out of hand to insert one die at a time because there are more than 5,000 cities, when I try to insert only one die at a time for sure .

  • Would not be a , in place of ; if you don’t need to repeat the header(insert .... )

  • You need to make an INSERT for each record. As there are many, make a script that manages it for you. Surely, you have the city data somewhere (a text file, for example). Make a script to go through this file and produce another file with Inserts for each city.

  • @rray I’ve tried both ways but always returns me the error in the second line

  • @Even Cantoni with multiple Insert headers makes me same error

  • @Matheusgoes, you said that one at a time works, so it must be some sort of separator that you need to use between one INSERT and another. I don’t remember FB enough to tell you exactly what that separator is, but it certainly exists.

  • Which version of fb are you using? tried EXECUTE BLOCK ?

  • as I said I’m new to firebid so I probably haven’t tried EXECUTE BLOCK , but I’ll search to see if it can be why

  • My Version of Firebird 2.5.0

Show 3 more comments

1 answer

2


To documentation of Firebird suggests, use EXECUTE BLOCK to perform multiple Inserts.

set term ^ ;
EXECUTE BLOCK AS BEGIN
INSERT INTO table1 (col1, col2) VALUES (2, 'two');
INSERT INTO table1 (col1, col2) VALUES (4, 'four');
INSERT INTO table1 (col1, col2) VALUES (5, 'five');
END^

To add the header to each line, use a text editor with regex support like Notepad++, press Ctrl+H

First check the option regular expression, in find typhoon ^(line start) and replace put the INSERT INTO CIDADE (CODIGO,NOME,ESTADO) VALUES, at the beginning of each line this strings will be added.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.