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 

execute insert query through 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
Packi
Beginner


Joined: 01 Jun 2007
Posts: 3
Topics: 2

PostPosted: Thu Jan 03, 2008 7:36 am    Post subject: execute insert query through REXX Reply with quote

I need to execute the following sql query through REXX:

Insert into table2 (select * from table1 where not exists(select * from table2 where table1.keyfield1 = table2.keyfield1))

i tried dynamically creating this sql in a variable. Then i prepared and executed this. It is giving SQLCODE of -104 while executing. But the SQL is fine when running in spufi.
Back to top
View user's profile Send private message
jim haire
Beginner


Joined: 30 Dec 2002
Posts: 140
Topics: 40

PostPosted: Thu Jan 03, 2008 2:58 pm    Post subject: Reply with quote

The query looks good. A -104 usually says that the SQL is not formatted quite correctly.

I would try the following options:
1. Put a Trace in your program and see what the contents of the variables are.
2. Use a "SAY variable" statement to see what the SQL looks like on your
screen.
3. Write your variable to a file and then turn HEX ON to verify that you don't
have any invalid characters in your SQL.
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Fri Jan 04, 2008 1:26 am    Post subject: Reply with quote

Packi,

Can you post an excerpt of your rexx code where this query is prepared and declared?
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
Packi
Beginner


Joined: 01 Jun 2007
Posts: 3
Topics: 2

PostPosted: Mon Jan 07, 2008 6:05 am    Post subject: Reply with quote

SQL6=Insert into table2 (select * from table1 where not exists(select * from table2 where table1.keyfield1 = table2.keyfield1))


ADDRESS DSNREXX "EXECSQL PREPARE S6 FROM :SQL6"
SAY 'RC:' RC
SAY 'SQLCODE:PREPARE(UPDATE)' SQLCODE

ADDRESS DSNREXX "EXECUTE S6"
SAY 'RC:' RC
SAY 'SQLCODE:UPDATE' SQLCODE*/
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: Mon Jan 07, 2008 7:41 am    Post subject: Reply with quote

put quotes around your statement when assigning it to variable SQL6 e.g.

SQL6 = "INSERT INTO TABLE......."
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
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