Unix Technical Forum

db2_all : escape * ' ( " in ksh

This is a discussion on db2_all : escape * ' ( " in ksh within the DB2 forums, part of the Database Server Software category; --> I am trying to escape the special characters while executing the following sql, but couldn't figure out a way. ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 01:30 AM
Prince Kumar
 
Posts: n/a
Default db2_all : escape * ' ( " in ksh

I am trying to escape the special characters while executing the
following sql, but couldn't figure out a way.

db2_all "db2 connect to mydb; db2 select * from table
(SNAPSHOT_CONTAINER ( '' , -1 ) ) as snp where TABLESPACE_NAME =
'MYTSP'; db2 terminate".

How would I get this successully executed?

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 01:30 AM
Ian
 
Posts: n/a
Default Re: db2_all : escape * ' ( " in ksh

Prince Kumar wrote:

> I am trying to escape the special characters while executing the
> following sql, but couldn't figure out a way.
>
> db2_all "db2 connect to mydb; db2 select * from table
> (SNAPSHOT_CONTAINER ( '' , -1 ) ) as snp where TABLESPACE_NAME =
> 'MYTSP'; db2 terminate".
>
> How would I get this successully executed?


Use the unix escape character, '\'.

db2_all "db2 connect to mydb; db2 \"select * from ...\"; db2 terminate"




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 01:32 AM
Prince Kumar
 
Posts: n/a
Default Re: db2_all : escape * ' ( " in ksh

Thanks Ian,

I already tried that. I got the following error.

db2_all "db2 connect to mydb; db2 \"select * from table
(SNAPSHOT_CONTAINER('', -1 )) as snp where TABLESPACE_NAME = 'TSSAM'
\";db2 terminate"

Database Connection Information

Database server = DB2/6000 8.1.5
SQL authorization ID = XXXXX
Local database alias = MYDB

SQL0104N An unexpected token "," was found following
"(SNAPSHOT_CONTAINER(".
Expected tokens may include: "<space>". SQLSTATE=42601
DB20000I The TERMINATE command completed successfully.
cdidev01: db2 connect to mydb completed ok

I tried to escape the "(" , "'" as well. But it did not help.

Thanks,
Prince.

Ian <ianbjor@mobileaudio.com> wrote in message news:<412aaa35_1@corp.newsgroups.com>...
> Prince Kumar wrote:
>
> > I am trying to escape the special characters while executing the
> > following sql, but couldn't figure out a way.
> >
> > db2_all "db2 connect to mydb; db2 select * from table
> > (SNAPSHOT_CONTAINER ( '' , -1 ) ) as snp where TABLESPACE_NAME =
> > 'MYTSP'; db2 terminate".
> >
> > How would I get this successully executed?

>
> Use the unix escape character, '\'.
>
> db2_all "db2 connect to mydb; db2 \"select * from ...\"; db2 terminate"
>
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 01:33 AM
Ian
 
Posts: n/a
Default Re: db2_all : escape * ' ( " in ksh

Prince Kumar wrote:

> Thanks Ian,
>
> I already tried that. I got the following error.
>
> db2_all "db2 connect to mydb; db2 \"select * from table
> (SNAPSHOT_CONTAINER('', -1 )) as snp where TABLESPACE_NAME = 'TSSAM'
> \";db2 terminate"


This exact syntax works just fine for me. Are you using a weird shell,
or do you have anything strange in your .profile, db2profile or
userprofile?




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 01:35 AM
Prince Kumar
 
Posts: n/a
Default Re: db2_all : escape * ' ( " in ksh

Hi Ian,

I am using ksh on AIX 5.2. I don't see any weird stuff in the .profile
or db2profile. If I do not have the "(" or any such spl characters it
works fine.

db2_all "db2 select agent_id from table(snapshot_lock(' ',-1) ) as
snap"

ksh: 0403-057 Syntax error at line 1 : `(' is not expected.

ksh: 0403-057 Syntax error at line 1 : `(' is not expected.

ksh: 0403-057 Syntax error at line 1 : `(' is not expected.

ksh: 0403-057 Syntax error at line 1 : `(' is not expected.

$ db2_all "db2 select 'no-conn' from sysibm.sysdummy1"

SQL1024N A database connection does not exist. SQLSTATE=08003
cdidev01: db2 select agent_id ... completed rc=4

SQL1024N A database connection does not exist. SQLSTATE=08003
cdidev01: db2 select agent_id ... completed rc=4

Note: I did not connect to the db. I just wanted to see whether the
syntax works or not

.................................................. ...........................
looks like
Ian <ianbjor@mobileaudio.com> wrote in message news:<412e3e64$1_1@corp.newsgroups.com>...
> Prince Kumar wrote:
>
> > Thanks Ian,
> >
> > I already tried that. I got the following error.
> >
> > db2_all "db2 connect to mydb; db2 \"select * from table
> > (SNAPSHOT_CONTAINER('', -1 )) as snp where TABLESPACE_NAME = 'TSSAM'
> > \";db2 terminate"

>
> This exact syntax works just fine for me. Are you using a weird shell,
> or do you have anything strange in your .profile, db2profile or
> userprofile?
>
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 01:36 AM
Prince Kumar
 
Posts: n/a
Default Re: db2_all : escape * ' ( " in ksh

Just an update.

db2_all 'db2 connect to mydb; db2 "select * from
table(snapshot_lockwait(chr(32),-1)) as snap "; db2 terminate'

The above works fine. But when I try to replace the chr(32) (ie the
space) with \' \', (ie quote-space-quote) I get the following error

ksh: 0403-057 Syntax error: `)' is not expected


gspk@yahoo.com (Prince Kumar) wrote in message news:<629275ba.0408231208.71a065c0@posting.google. com>...
> I am trying to escape the special characters while executing the
> following sql, but couldn't figure out a way.
>
> db2_all "db2 connect to mydb; db2 select * from table
> (SNAPSHOT_CONTAINER ( '' , -1 ) ) as snp where TABLESPACE_NAME =
> 'MYTSP'; db2 terminate".
>
> How would I get this successully executed?
>
> Thanks.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com