View previous topic :: View next topic |
Author |
Message |
Packi Beginner
Joined: 01 Jun 2007 Posts: 3 Topics: 2
|
Posted: Thu Jan 03, 2008 7:36 am Post subject: execute insert query through REXX |
|
|
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 |
|
 |
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Thu Jan 03, 2008 2:58 pm Post subject: |
|
|
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 |
|
 |
vivek1983 Intermediate

Joined: 20 Apr 2006 Posts: 222 Topics: 24
|
Posted: Fri Jan 04, 2008 1:26 am Post subject: |
|
|
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 |
|
 |
Packi Beginner
Joined: 01 Jun 2007 Posts: 3 Topics: 2
|
Posted: Mon Jan 07, 2008 6:05 am Post subject: |
|
|
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 |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Mon Jan 07, 2008 7:41 am Post subject: |
|
|
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 |
|
 |
|
|