PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
saitemre
Posts: 2
Joined: 11 Aug 2010 05:30

PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!

#1 Post by saitemre » 11 Aug 2010 05:38

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?

aGerman
Expert
Posts: 4693
Joined: 22 Jan 2010 18:01
Location: Germany

Re: PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!

#2 Post by aGerman » 11 Aug 2010 06:11

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

saitemre
Posts: 2
Joined: 11 Aug 2010 05:30

Re: PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!

#3 Post by saitemre » 11 Aug 2010 06:46

thank u so much, 2nd way helped us and it works...

jeb
Expert
Posts: 1057
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: PLEASE HELP!!!I AM STUCKED!!!ESCAPE CHARACTER!!!

#4 Post by jeb » 26 Sep 2010 02:25

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

Post Reply