[firebase-br] RES: vários linhas de insert

Luis Gustavo gustavo em staldendecor.com.br
Sex Set 26 08:45:55 -03 2014


vlw pessoal estarei testando!







Atenciosamente / Best Regards,
Luís Gustavo

Diretor

+55 19 3894.3338 | 3894.3321
  www.staldendecor.com.br
 



-----Mensagem original-----
De: lista [mailto:lista-bounces em firebase.com.br] Em nome de Alexandre
Pereira Bühler
Enviada em: quinta-feira, 25 de setembro de 2014 16:48
Para: FireBase
Assunto: Re: [firebase-br] vários linhas de insert

Não sei se é oque você quer:
fonte: http://www.firebirdfaq.org/faq336/


  How to insert multiple rows in a single statement?


There are various approaches. For example, if you wish to insert these:

2 two
4 four
5 five

you can use UNIONs:

INSERT INTO table1 (col1, col2)
SELECT 2, 'two ' FROM RDB$DATABASE UNION ALL SELECT 4, 'four' FROM
RDB$DATABASE UNION ALL SELECT 5, 'five' FROM RDB$DATABASE;

Please note that datatypes must match, esp. if you use Firebird 1.x. In the
above example, 'four' and 'five' are varchar(4), while 'two' would evaluate
to varchar(3) and you would get an error with Firebird 1.x. To work around
this, you can use CAST or, in this case, add anoter space after the word:
two, to make it 'two '.

You can also use EXECUTE BLOCK (with Firebird 2.0 and above):

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^


Do you find this FAQ incorrect or incomplete? Please e-mail
<mailto:faq em firebirdfaq.org> us what needs to be changed. To ensure quality,
each change is checked by our editors (and often tested on live Firebird
databases), before it enters the main FAQ database. If you desire so, the
changes will be credited to your name. To learn more, visit our add content
<http://www.firebirdfaq.org/addContent.php> page.

If you are a commercial tool maker and your tool features a great way to
handle the issue written about in this FAQ, please check out our
advertisement <http://www.firebirdfaq.org/marketing.php> page.



All contents are copyright © 2007-2014 FirebirdFAQ.org unless otherwise
stated in the text.


Alexandre Pereira Bühler
Linux User: 397.546

Simão &  Bühler Ltda (Infobrindes)
http://www.simaoebuhler.com.br
alexandre em simaoebuhler.com.br
Telefone: (41) 3039-5428

Infobrindes (Simão &  Bühler Ltda)
Brindes e material promocional.
http://www.infobrindes.com.br
karin em infobrindes.com.br
Telefone: (41) 3082-8667



______________________________________________
FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
Para saber como gerenciar/excluir seu cadastro na lista, use:
http://www.firebase.com.br/fb/artigo.php?id=1107
Para consultar mensagens antigas: http://firebase.com.br/pesquisa





Mais detalhes sobre a lista de discussão lista