On Mar 28, 2007, at 6:03 PM, Dr Gerard Hammond wrote:
> At 5:41 PM -0600 28/3/07, Norman Palardy wrote:
>> On Mar 28, 2007, at 5:25 PM, Dr Gerard Hammond wrote:
>>
>>> Hi,
>>>
>>> I have a long file full of INSERT, UPDATE and SELECT statements.
>>> Does anybody have a piece of RegEx code that'll split the lines
>>> reliably into individual SQL statements.
>>> RegEx and I don't normally get on.
>>>
>>> Files typically look like this.
>>
>> Do you need to maintain returns in the textual items you have in the
>> mail or are those long fields that have been wrapped by mail ?
>
>
> Those CRs are real.
>
>
>>
>> If not I'd try to do this in 2 steps in BBEdit :)
>
> so far so good. That's where it is now ;-)
You know the old saying about great minds thinking alike :)
>> Remove all line endings
>> Then turn all ; into ; + an end of line
>
>
> But what happens to a field that might look like this
>
> UPDATE t1 set f2='(There is nothing like a dame); Nothing...'
>
> Column data in the SQL may have ); in there....
That wasn't clear that it may contain that
It might start something like
INSERT into .* ( .* ) values ( ... omg ! )
or UPDATE .* SET .* = .... omg ! ......
or SELECT .* FROM
but a regex for the values could be nasty because you have a lot of
possibilities
Even the BNF for SQL is pretty complex
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>