MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL IN REXX

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue Jul 08, 2008 12:02 pm    Post subject: SQL IN REXX Reply with quote

Hi all,

I am trying to write a sql in rexx but its failing when I include the where condition

[code:1:58a32273de]
000100 /* REXX */
001000 /* THIS IS A DB2 REXX FOR FETCHING ROWS FROM A CURSOR*/
001010 /* TRACE I */
001100 PARSE ARG SSID
001110 SSID = DSNT
001120 TNAME = 'XXXXX'
001200 "SUBCOM DSNREXX"
001300 IF RC THEN
001400 S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
001500 /* */
001600 /* CONNECT TO THE DB2 SUB-SYSTEM */
001700 /* */
001710 TRACE R
001800 ADDRESS DSNREXX "CONNECT" SSID
001900 IF SQLCODE
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Tue Jul 08, 2008 1:28 pm    Post subject: Reply with quote

Try put single quote around TNAME:
Code:

 SQLSTMT = ,                                                             
    "SELECT DBNAME",                                                       
    "FROM SYSIBM.SYSTABLES  WHERE NAME = '"TNAME"'"   
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Jul 09, 2008 12:18 am    Post subject: Reply with quote

Also, halt your processing once you find an error, then you will not be taking up resources trying to do things that will not work.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Wed Jul 09, 2008 12:56 am    Post subject: Reply with quote

Danm,

I got this error when I changed like that

[code:1:1304077915]


19 +++ SQLSTMT = ,
'SELECT DBNAME', '
FROM SYSIBM.SYSTABLES WHERE NAME = '"TNAME"'" /*
*/ /* DECLARE THE
CURSOR */ /*
*/ ADDRESS DSNREXX "EXECSQL DECL
ARE C1 CURSOR FOR S1" IF SQLCODE
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Wed Jul 09, 2008 7:55 am    Post subject: Reply with quote

Look at the usage of " and ' in the posting of Danm and change your statement accordingly. You didn't get it right.

regards
Christian
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Jul 09, 2008 11:20 am    Post subject: Reply with quote

You appear to have extra quotes on your SELECT line as well. Use double quotes around your strings just to make things clearer.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Wed Jul 09, 2008 10:23 pm    Post subject: Reply with quote

Oops sorry for that and I done it and the REXX is working fine Laughing
Thanks danm,CZerfas,Nic Clouston
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group