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 

Using REXX and DB2 - Declare Global Temporary Table

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


Joined: 05 Jan 2012
Posts: 47
Topics: 11

PostPosted: Mon Nov 25, 2013 11:21 am    Post subject: Using REXX and DB2 - Declare Global Temporary Table Reply with quote

I'm getting an error when I attempt the following in REXX. The same statement executes successfully in TSO/SPUFI. What Host Variable is it looking for?

Code:
EXECUTE IMMEDIATE DECLARE GLOBAL TEMPORARY TABLE SESSION.PGMTBL 
                          (PROGNAME        CHAR(8)       NOT NULL
                          ,SECTNO          SMALLINT             
                          ,QUERYNO         INTEGER               
                          ,CONTOKEN        CHAR(16)      NOT NULL
                          ,SQL_TEXT        VARCHAR(3000) NOT NULL
                          )                                     
                          CCSID EBCDIC                           
                          ON COMMIT PRESERVE ROWS               
                                                                 
SQLCA:                                                           
   SQLCODE  ="-104"                                             
   SQLSTATE ="42601"                                             
   SQLWARN  =" , , , , , , , , , , "                             
   SQLERRD  ="0,0,0,0,0,0"                                       
   SQLERRP  ="DSNTZEXE"                                         
   SQLERRMC ="DECLARE <HOST-VARIABLE>"


The manual states:

Quote:
You cannot execute a SELECT, INSERT, UPDATE, MERGE, or DELETE statement that contains host variables. Instead, you must execute PREPARE on the statement, with parameter markers substituted for the host variables, and then use the host variables in an EXECUTE, OPEN, or FETCH statement.


However I am not executing any of the above mentioned statements, just a DECLARE.

Thanks,
-Roy[/code]
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Nov 25, 2013 11:38 am    Post subject: Re: Using REXX and DB2 - Declare Global Temporary Table Reply with quote

RoyKMathur wrote:
I'm getting an error when I attempt the following in REXX. The same statement executes successfully in TSO/SPUFI. What Host Variable is it looking for?


Roy,

try this

Code:


SQL_STATEMENT = "DECLARE GLOBAL TEMPORARY TABLE SESSION.PGMTBL",
                "(PROGNAME        CHAR(8)       NOT NULL",
                ",SECTNO          SMALLINT",
                ",QUERYNO         INTEGER",
                ",CONTOKEN        CHAR(16)      NOT NULL",
                ",SQL_TEXT        VARCHAR(3000) NOT NULL",
                ")",                                     
                "CCSID EBCDIC".                           
                "ON COMMIT PRESERVE ROWS"

RUNSTMT = 'EXECUTE IMMEDIATE :SQL_STATEMENT'

ADDRESS DSNREXX "EXECSQL" RUNSTMT

IF SQLCODE ^= 0 THEN ....
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RoyKMathur
Beginner


Joined: 05 Jan 2012
Posts: 47
Topics: 11

PostPosted: Mon Nov 25, 2013 12:58 pm    Post subject: Reply with quote

That fixed it! Thanks Kolusu.
Back to top
View user's profile Send private message
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