IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX - DB2 query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kansassho

New User


Joined: 31 Mar 2008
Posts: 14
Location: kansas city

PostPosted: Fri Jul 17, 2009 4:42 pm
Reply with quote

I am facing problem while executing a Sql query having two table in use.
Dont we execute a SQL query having two table -like nested sql or join.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jul 17, 2009 4:53 pm
Reply with quote

What exactly is the problem here.
Back to top
View user's profile Send private message
kansassho

New User


Joined: 31 Mar 2008
Posts: 14
Location: kansas city

PostPosted: Tue Jul 21, 2009 4:05 pm
Reply with quote

I am executing mu query using DSNREXX routine.
My code looks like

Code:
SQLSTMT = "SELECT  DISTINCT A.COMPANY_CODE,A.MASTER_ID       
FROM MLQV1b0A.CONTF A                                       
WHERE (A.RESIDENT_STATE = 'OC ' OR  A.US_CITIZEN_IND = 'N')"
ADDRESS DSNREXX "EXECSQL DECLARE C1 CURSOR FOR S1"           
say rc                                                       
If SQLCODE <> 0 Then Call SQLCA                             
ADDRESS DSNREXX "EXECSQL PREPARE S1 FROM :SQLSTMT"           
say rc                                                       
If SQLCODE <> 0 Then Call SQLCA                             
ADDRESS DSNREXX "EXECSQL OPEN C1"                           
say rc                                                       
If SQLCODE <> 0 Then Call SQLCA                             
/* CHECKING SQL CODE */                                     
DO UNTIL(SQLCODE \= 0)                                       
   "EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA"             
   IF(SQLCODE = 0) THEN DO                                   
        say 'in'                                             
        LINE1 = ''                                           
        LINE1 = ''                           
        LINE2 = ''                           
        LINE1 =LINE1 OUTSQLDA.2.SQLDATA       
        LINE2 =LINE2 OUTSQLDA.4.SQLDATA       
        SAY     LINE1 LINE2                   
   END                                       
   ELSE                                       
        SAY SQLCODE                           
END                                           




Now my question is the variable SQLSTMT is not able to take a query of more than 250 character.

Is there any way, so that I can get any query of more than 250 character.

Please suggest
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Jul 21, 2009 6:39 pm
Reply with quote

Code:
SQLSTMT = "SELECT  DISTINCT A.COMPANY_CODE,A.MASTER_ID       
FROM MLQV1b0A.CONTF A                                       
WHERE (A.RESIDENT_STATE = 'OC ' OR  A.US_CITIZEN_IND = 'N')"

I like to keep my statements well formatted:
Code:
SQLSTMT = "SELECT  DISTINCT A.COMPANY_CODE,A.MASTER_ID",
   "FROM MLQV1b0A.CONTF A",
   "WHERE (A.RESIDENT_STATE = 'OC ' OR  A.US_CITIZEN_IND = 'N')"

I have queries like that with more than 400 chars.
Back to top
View user's profile Send private message
wanderer

Active User


Joined: 05 Feb 2007
Posts: 199
Location: Sri Lanka

PostPosted: Wed Jul 22, 2009 12:58 am
Reply with quote

What is the error you are getting? Please post the entire error message.
Back to top
View user's profile Send private message
Venkat1001

New User


Joined: 25 Feb 2008
Posts: 12
Location: chennai

PostPosted: Mon Aug 31, 2009 8:01 am
Reply with quote

SQLSTMT1 = "SELECT DISTINCT A.COMPANY_CODE,A.MASTER_ID"
SQLSTMT2 = "FROM MLQV1b0A.CONTF A"
SQLSTMT3 = "WHERE (A.RESIDENT_STATE = 'OC ' OR A.US_CITIZEN_IND = 'N')"
SQLSTMT = SQLSTMT1||SQLSTMT2||SQLSTMT3

try this and it works.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top