I have an insert statement that is of the form
INSERT INTO pubs VALUES (16590,'Header','HEADER1995','1995-00-00',1549,NULL,'tp','NOVEL',NULL,NULL,'$5.95',NULL),(16591,'Headhunter','BKTG16613','1993-00-00',11,'422','pb','NOVEL','0450591123',NULL,'L4.99',NULL),(16592,'Headhunter','BKTG03173','1994-00-00',282,'440','hc','NOVEL','0517598272',NULL,'$23.00',NULL);
However, it's something like a million characters long. It's from a mysql export that I need to import into a different database. My system is failing from stack overflows.
To fix it I want to use a regex Matcher to go through and for every 100 values, insert a new INSERT line. So, if we split it for every one, the result would be to convert this:
INSERT INTO pubs VALUES (1,2,3),(2,3,4),(4,5,6)
INSERT INTO pubs VALUES (1,2,3);
INSERT INTO pubs VALUES (2,3,4);
INSERT INTO pubs VALUES (4,5,6)
I don't know how to write a regex that will properly match everything including string values that may contain delimeters. For instance, I have no idea how to match against something like:
INSERT INTO pubs VALUES ('I (by which I mean we), really like Jill''s face.');
Alternatively, I suppose you could tell me how to get derby to not choke on the original megabyte-long insert statement.