in reply to Re^2: Parse complex SQL statement
in thread Parse complex SQL statement
If this is an internal utility, you could accomplish your goal with something like
but this has a number of potential issues: nested queries will parse incorrectly, it fails to consider quoted names and string literals, ... Which is why I usually suggest canned code.m/insert\s+into\s+(\S+)\s*\(\s*([^)]+?)\s*\)\s* (?:values\s*\(\s*([^)]+?)\s*\) | select\s*(.+?)\s+(?:where|order) ) /ix
Update: Or misparse by me; the regular expression should read
Of course, your posted SQL doesn't actually correspond to the SQL posted in the original_string field in Re^2: Parse complex SQL statement.m/insert\s+into\s+(\S+)\s*\(\s*([^)]+?)\s*\)\s* (?:values\s*\(\s*([^)]+?)\s*\) | select\s*(.+?)\s+(?:from\b) ) /ix
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Parse complex SQL statement
by perl_help26 (Beadle) on Jun 16, 2014 at 09:29 UTC | |
by kennethk (Abbot) on Jun 16, 2014 at 19:22 UTC |