Play macro several times

Answered

I am looking for possibility to generate batch of queries (insert/update/..).

Example:

I have a list of data which I would like insert:
123
234
2345
435

and I would like to achieve this:
INSERT INTO MY_TABLE (COLUMN) VALUES ('123');

INSERT INTO MY_TABLE (COLUMN) VALUES ('234');

INSERT INTO MY_TABLE (COLUMN) VALUES ('2345');

INSERT INTO MY_TABLE (COLUMN) VALUES ('435');

For the moment, I am using Notepad++, where I am recording macro for one row and then I am running macro till end of file or I am setting number of executions.

I have discovered that DataGrip has a possibility to record macro, but macro can be run only once.

So, for each line I need to go to Menu-->Edit-->Macros-->Play Back Last Macro.. (btw. I haven't found possibility to customize toolbar, that macro can be easily accessible, is there any?).

Or maybe there is other workaround?

6 comments
Comment actions Permalink

Hello Marcin,
You can generate sql insert/update statements from the file with data using custom Data Extractors feature. Please check this my answer: https://devnet.jetbrains.com/message/5567774#5567774 .

0
Comment actions Permalink

Thank you Andrey for your reply.

That's really nice feature and it's working as expected, but I can't manage to add quotes to values.

Is there any settings to do that?

0
Comment actions Permalink

If you already have quotes in the data file, just configure the table format so that the quotes were not stripped off. Remote quotation escape here

Screen Shot 2016-01-14 at 16.29.51.png
then dump resulted table as insert statements.

0
Comment actions Permalink

I understand that the help here is directed at the problem statement of generating SQL insert statements, but the post title is about executing a macro multiple times. It would be nice if that were addressed as well since this is where a search of that topic brings people.

0
Comment actions Permalink

It would be very useful if there was an option when playing a macro to repeat until the end of file. Its much easier than binding a particular macro to a key

0
Comment actions Permalink

It looks like there is long awaiting feature request https://youtrack.jetbrains.com/issue/DBE-177

0

Please sign in to leave a comment.