Subject Re: Exporting insert statements - qli?
Author Smarts Broadcast Systems
--- In firebird-support@yahoogroups.com, Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
>
> What do you intend to do with the output?

The output, once in plain text form, will then be fed into awk for
subsequent massaging.

> I'm asking because it takes time to prepare a statement, and if you
have
> 100000 insert statements that you want to execute, that is going to
> take considerably longer than preparing a statement once, fill in
> parameters 100000 times and execute the already prepared statement
> 100000 times.

Speed is of no concern whatsoever, this is for a bootstrap situation
where it can take days to perform the insertions as far as we're
concerned. Furthermore, we're dealing with < 10,000 rows per table.

> If you know which table and fields you want to export, then I think you
> could even use isql to create the insert statements for you, e.g. I
> would expect something like:
>
> SELECT 'INSERT INTO PERSON(PID, NAME, COUNTRY) VALUES '||PID||',
> '''||NAME||''', '''||COUNTRY||''''
> FROM PERSON
>
> to produce a result similar to:
> INSERT INTO PERSON(PID, NAME, COUNTRY) VALUES 1, 'Set', 'Norway'
> INSERT INTO PERSON(PID, NAME, COUNTRY) VALUES 2, 'Helen', 'Australia'
> INSERT INTO PERSON(PID, NAME, COUNTRY) VALUES 3, 'Martijn', 'Holland'
>
> (though I don't use isql myself, and don't know how to export to a
> textfile).

While waiting for a reply, I just ended up writing a Perl script that
performs much the same as ``pg_dump'' (for those familiar with that
command in PostgreSQL).

Thanks for your help -- I only wish there was more approachable
documentation for ``qli'' (but I'm aware that it's a very old command,
largely superseded by ``isql'').

> Smarts Broadcast Systems wrote:
> > I'm doing my best to read the ``qli_syntax.pdf'' manual but am finding
> > the going rough, hence this plea for help.
> >
> > The goal is to dump the contents of a table into a text file of
> > ``INSERT'' statements. There are mentions of such capabilities with
> > third-party GUI tools but I am hoping that a non-graphical, scriptable
> > command-line tool such as ``qli'' already has that capability.