Hi,
On "DB2 WSE v8.2 fp9 on Windows XP SP2" I would like to execute Windows batch file with SQL statements. My batch file looks like this:
Code:
db2 create table db2admin.tab1 (col1 char(10))
db2 insert into db2admin.tab1 values ('abc'),('bac'),('caa')
db2 select * from db2admin.tab1
Select returns the following result:
Code:
COL1
----------
abc
bac
caa
So far so good, but deleting all rows with like command (as follows)...:
Code:
db2 delete from db2admin.tab1 where col1 like '%a%'
... returs following warning: "SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table. SQLSTATE=02000".
The above problem appears because Windows batch file recognizes %a% as system variable. Because system variable %a% does not exist the value of %a% is empty string. So SQL looks like:
which is obvious no rows are deleted.
So how to write "... where col1 like '%a%' " in batch file?
Thanks a lot,
Grofaty