dear my friends, i need to create a batch file for my oracle database on windows and for this i need to write a "select" statement,
(i dont have any problem for the first 2 lines, they work)
For /F "tokens=* delims=" %%A in ('Type a.txt') Do Set MyVar=%%A
Echo [%MyVar%]
set sql=select 'del ' || name from v$archived_log where sequence#>%MyVar% and applied='YES';
echo %sql% > s.sql
shortly, i am reading MyVar value from a text file and i want to write a select statement with using this value, also i want to write my sql statement to a file whose name is s.sql
my aim is to write to the s.sql exactly this:
select 'del ' || name from v$archived_log where sequence#>23456 and applied='YES';
but i cant escape "||" characters, i tried everything (like ^) but i couldnt succedded. can u help me?
PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!
Moderator: DosItHelp
Re: PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!
I see two possible ways:
set sql=select 'del ' ^^^|^^^| name from v$archived_log where sequence#^^^>%MyVar% and applied='YES';
set "sql=select 'del ' ^|^| name from v$archived_log where sequence#^>%MyVar% and applied='YES';"
Regards
aGerman
set sql=select 'del ' ^^^|^^^| name from v$archived_log where sequence#^^^>%MyVar% and applied='YES';
set "sql=select 'del ' ^|^| name from v$archived_log where sequence#^>%MyVar% and applied='YES';"
Regards
aGerman
Re: PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!
thank u so much, 2nd way helped us and it works...
Re: PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!
I see a possible third way, so you don't need to escape anything (except " and %)
set "sql=select 'del ' || name from v$archived_log where sequence#>%MyVar% and applied='YES';"
setlocal EnableDelayedExpansion
echo !sql!
jeb
set "sql=select 'del ' || name from v$archived_log where sequence#>%MyVar% and applied='YES';"
setlocal EnableDelayedExpansion
echo !sql!
jeb