Reputation: 381
I would like to create a script that will be turned sql command of the form which can be assigned to a string in Delphi. Example (text in .txt file):
select name,species,quantity from lamas
where species='Alpaca'
and name='Andrew'
I want :
'select name,species from lamas '+
'where species='Alpaca' '+
'and name='Andrew' ';
At the beginning of each line txt file I would add '
On end of line '+'
And on end file instead '+'
simple ';
.
Upvotes: 1
Views: 110
Reputation: 24144
Here is the Windows CMD script:
@echo OFF
setlocal enableDelayedExpansion
set j="@@@@@"
for /F "tokens=1 delims=" %%i in ('type %1') do (
IF NOT !j!== "@@@@@" (
echo '!j!'+ >>output.txt
)
set j=%%i
set j=!j:'=''!
)
echo '!j!'; >>output.txt
If you call it with your .txt file parameter
script.cmd example.txt
You'll get output.txt
file:
'select name,species,quantity from lamas'+
'where species=''Alpaca'''+
'and name=''Andrew''';
Note: in Delphi you should also change single quotas around strings ('Alpaca','Andrew') in the SQL command with double quotas. This script implements this.
Upvotes: 2