Extraction of multi rows queries

Sometimes, I had encountered the problem with getting the full query which was divided into many rows (as a result of developer scripting or a literal containing NEW LINE).
To obtaing the full query (I needed mainly REPLACE/INSERT) I use the following trick:

#!/bin/bash

# get the content w/o white NL, EOL.
Input=$(cat < /tmp/my.file)
# DML instructions has to be pointed out.
echo $Input | sed 's/; \(REPLACE\|UPDATE\|DELETE\|INSERT\)/;\n\1/gI'

Voila!

  1. No comments yet.

  1. No trackbacks yet.