473,396 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DB2 and REXX

Hi all,

I am a little puzzled.. I am trying to make some insert into an DB2
using SQLEXEC and it just does not work...
code looks like that:
/*
// Initialize SQLEXEC interface
*/
parse version rexxType .
parse source platform .
trace 'o'
if platform == 'AIX/6000' & rexxType == 'REXXSAA' then
do
rcy = SysAddFuncPkg("db2rexx")
end
else
do
if RxFuncQuery('SQLDBS') <0 then
rcy = RxFuncAdd( 'SQLDBS', 'db2ar', 'SQLDBS' )
if RxFuncQuery('SQLEXEC') <0 then
rcy = RxFuncAdd( 'SQLEXEC', 'db2ar', 'SQLEXEC' )
if RxFuncQuery('SQLDB2') <0 then
rcy = RxFuncAdd( 'SQLDB2', 'db2ar', 'SQLDB2' )
end
CALL SQLDBS 'START DATABASE MANAGER'
IF SQLCA.SQLCODE = -1026 then
SAY "DB2 DATABASE MANAGER ALREADY STARTED"
ELSE
CALL RxSqlCodeCheck 'START DATABASE MANAGER'
/*
// Initialize global variables
*/
database = 'DBNAME'
call SQLEXEC 'CONNECT TO 'database
if RxSqlCodeCheck() \= 1 then
return 0
DO A=1 TO LOAD.0 (<------ READ a stem e.g IMPORT FROM "G:aaaaa
\bbb.cc.dd" OF ASC METHOD L (6 13, 15 22, 24 33) ALLOW WRITE ACCESS
MESSAGES "G:\aa\bb\cc.txt" INSERT INTO XXXXX.01.YYYY_zz (aaaaa, bbbbb,
cccccc);
/*
// Execute sql
*/
st=load.a
CALL SQLEXEC "EXECUTE IMMEDIATE :st"
if RxSqlCodeCheck() \= 1 then
return 0
END

I get an
SQL0104N An unexpected "IMPORT FROM "G:aaaaa\bbb" was found following
"BEGIN-OF-STATEMENT". Expected tokens may includes: "<values>".
SQLSTATE=42601.

Strange is when I start the control center and copy paste the same
statement it works...??? Any Idea??

Regards Chris

Apr 10 '07 #1
6 6118
<cb*****@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
Hi all,

I am a little puzzled.. I am trying to make some insert into an DB2
using SQLEXEC and it just does not work...
code looks like that:
/*
// Initialize SQLEXEC interface
*/
parse version rexxType .
parse source platform .
trace 'o'
if platform == 'AIX/6000' & rexxType == 'REXXSAA' then
do
rcy = SysAddFuncPkg("db2rexx")
end
else
do
if RxFuncQuery('SQLDBS') <0 then
rcy = RxFuncAdd( 'SQLDBS', 'db2ar', 'SQLDBS' )
if RxFuncQuery('SQLEXEC') <0 then
rcy = RxFuncAdd( 'SQLEXEC', 'db2ar', 'SQLEXEC' )
if RxFuncQuery('SQLDB2') <0 then
rcy = RxFuncAdd( 'SQLDB2', 'db2ar', 'SQLDB2' )
end
CALL SQLDBS 'START DATABASE MANAGER'
IF SQLCA.SQLCODE = -1026 then
SAY "DB2 DATABASE MANAGER ALREADY STARTED"
ELSE
CALL RxSqlCodeCheck 'START DATABASE MANAGER'
/*
// Initialize global variables
*/
database = 'DBNAME'
call SQLEXEC 'CONNECT TO 'database
if RxSqlCodeCheck() \= 1 then
return 0
DO A=1 TO LOAD.0 (<------ READ a stem e.g IMPORT FROM "G:aaaaa
\bbb.cc.dd" OF ASC METHOD L (6 13, 15 22, 24 33) ALLOW WRITE ACCESS
MESSAGES "G:\aa\bb\cc.txt" INSERT INTO XXXXX.01.YYYY_zz (aaaaa, bbbbb,
cccccc);
/*
// Execute sql
*/
st=load.a
CALL SQLEXEC "EXECUTE IMMEDIATE :st"
if RxSqlCodeCheck() \= 1 then
return 0
END

I get an
SQL0104N An unexpected "IMPORT FROM "G:aaaaa\bbb" was found following
"BEGIN-OF-STATEMENT". Expected tokens may includes: "<values>".
SQLSTATE=42601.

Strange is when I start the control center and copy paste the same
statement it works...??? Any Idea??

Regards Chris
Load is not a SQL statement, it is a command. The Control Center is designed
to run commands or SQL statements.
Apr 10 '07 #2
On Apr 10, 10:12 am, "Mark A" <nob...@nowhere.comwrote:
<cber...@gmail.comwrote in message

news:11**********************@n76g2000hsh.googlegr oups.com...


Hi all,
I am a little puzzled.. I am trying to make some insert into an DB2
using SQLEXEC and it just does not work...
code looks like that:
/*
// Initialize SQLEXEC interface
*/
parse version rexxType .
parse source platform .
trace 'o'
if platform == 'AIX/6000' & rexxType == 'REXXSAA' then
do
rcy = SysAddFuncPkg("db2rexx")
end
else
do
if RxFuncQuery('SQLDBS') <0 then
rcy = RxFuncAdd( 'SQLDBS', 'db2ar', 'SQLDBS' )
if RxFuncQuery('SQLEXEC') <0 then
rcy = RxFuncAdd( 'SQLEXEC', 'db2ar', 'SQLEXEC' )
if RxFuncQuery('SQLDB2') <0 then
rcy = RxFuncAdd( 'SQLDB2', 'db2ar', 'SQLDB2' )
end
CALL SQLDBS 'START DATABASE MANAGER'
IF SQLCA.SQLCODE = -1026 then
SAY "DB2 DATABASE MANAGER ALREADY STARTED"
ELSE
CALL RxSqlCodeCheck 'START DATABASE MANAGER'
/*
// Initialize global variables
*/
database = 'DBNAME'
call SQLEXEC 'CONNECT TO 'database
if RxSqlCodeCheck() \= 1 then
return 0
DO A=1 TO LOAD.0 (<------ READ a stem e.g IMPORT FROM "G:aaaaa
\bbb.cc.dd" OF ASC METHOD L (6 13, 15 22, 24 33) ALLOW WRITE ACCESS
MESSAGES "G:\aa\bb\cc.txt" INSERT INTO XXXXX.01.YYYY_zz (aaaaa, bbbbb,
cccccc);
/*
// Execute sql
*/
st=load.a
CALL SQLEXEC "EXECUTE IMMEDIATE :st"
if RxSqlCodeCheck() \= 1 then
return 0
END
I get an
SQL0104N An unexpected "IMPORT FROM "G:aaaaa\bbb" was found following
"BEGIN-OF-STATEMENT". Expected tokens may includes: "<values>".
SQLSTATE=42601.
Strange is when I start the control center and copy paste the same
statement it works...??? Any Idea??
Regards Chris

Load is not a SQL statement, it is a command. The Control Center is designed
to run commands or SQL statements.- Hide quoted text -

- Show quoted text -
Thanks Mark, but the stem is called LOAD but the sql looks like that:

"IMPORT FROM "G:aaaaa\bbb.cc.dd" OF ASC METHOD L (6 13, 15 22, 24 33)
ALLOW WRITE ACCESS MESSAGES "G:\aa\bb\cc.txt" INSERT INTO XXXXX.
01.YYYY_zz (aaaaa, bbbbb, cccccc);"

You think it would work with load??

Apr 10 '07 #3
On Apr 10, 7:36 am, "cber...@gmail.com" <cber...@gmail.comwrote:
Hi all,

I am a little puzzled.. I am trying to make some insert into an DB2
using SQLEXEC and it just does not work...
code looks like that:
/*
// Initialize SQLEXEC interface
*/
parse version rexxType .
parse source platform .
trace 'o'
if platform == 'AIX/6000' & rexxType == 'REXXSAA' then
do
rcy = SysAddFuncPkg("db2rexx")
end
else
do
if RxFuncQuery('SQLDBS') <0 then
rcy = RxFuncAdd( 'SQLDBS', 'db2ar', 'SQLDBS' )
if RxFuncQuery('SQLEXEC') <0 then
rcy = RxFuncAdd( 'SQLEXEC', 'db2ar', 'SQLEXEC' )
if RxFuncQuery('SQLDB2') <0 then
rcy = RxFuncAdd( 'SQLDB2', 'db2ar', 'SQLDB2' )
end
CALL SQLDBS 'START DATABASE MANAGER'
IF SQLCA.SQLCODE = -1026 then
SAY "DB2 DATABASE MANAGER ALREADY STARTED"
ELSE
CALL RxSqlCodeCheck 'START DATABASE MANAGER'
/*
// Initialize global variables
*/
database = 'DBNAME'
call SQLEXEC 'CONNECT TO 'database
if RxSqlCodeCheck() \= 1 then
return 0
DO A=1 TO LOAD.0 (<------ READ a stem e.g IMPORT FROM "G:aaaaa
\bbb.cc.dd" OF ASC METHOD L (6 13, 15 22, 24 33) ALLOW WRITE ACCESS
MESSAGES "G:\aa\bb\cc.txt" INSERT INTO XXXXX.01.YYYY_zz (aaaaa, bbbbb,
cccccc);
/*
// Execute sql
*/
st=load.a
CALL SQLEXEC "EXECUTE IMMEDIATE :st"
if RxSqlCodeCheck() \= 1 then
return 0
END

I get an
SQL0104N An unexpected "IMPORT FROM "G:aaaaa\bbb" was found following
"BEGIN-OF-STATEMENT". Expected tokens may includes: "<values>".
SQLSTATE=42601.

Strange is when I start the control center and copy paste the same
statement it works...??? Any Idea??

Regards Chris
The cause of your problem is that you are using the SQLEXEC API
instead of the SQLDB2 or SQLDBS api.
The SQLEXEC API can only be used for SQL, it cannot be used for
commands like import or load.
Hope this helps.
Apr 10 '07 #4
<snip>
The cause of your problem is that you are using the SQLEXEC API
instead of the SQLDB2 or SQLDBS api.
The SQLEXEC API can only be used for SQL, it cannot be used for
commands like import or load.
Hope this helps.
Yes I was already very happy and was thinking now I got it.... but
unfortunately I get some other errors:
SQL7016N Invalid syntax provided to the SQLDB2 interface. Related
Error: "DB21061E". sqlcode=-7016.....

Apr 10 '07 #5
This is a working import statement.

call SQLDBS('import from C:\download\OB546P.new of asc method L using
:col_data messages msg.imp INSERT_UPDATE into userid.OB546P')
col_data.0 = 16
col_data.1 = 1 /* start */
col_data.2 = 12 /* stop */
col_data.3 = 13
col_data.4 = 22
col_data.5 = 23 /* pair 3 start */
col_data.6 = 23 /* pair 3 stop */
col_data.7 = 24
col_data.8 = 35
col_data.9 = 36
col_data.10 = 39
col_data.11 = 40
col_data.12 = 48
col_data.13 = 49
col_data.14 = 57
col_data.15 = 58
col_data.16 = 60
Apr 10 '07 #6
On Apr 10, 5:33 pm, "cber...@gmail.com" <cber...@gmail.comwrote:
<snip>
The cause of your problem is that you are using the SQLEXEC API
instead of the SQLDB2 or SQLDBS api.
The SQLEXEC API can only be used for SQL, it cannot be used for
commands like import or load.
Hope this helps.

Yes I was already very happy and was thinking now I got it.... but
unfortunately I get some other errors:
SQL7016N Invalid syntax provided to the SQLDB2 interface. Related
Error: "DB21061E". sqlcode=-7016.....
I got it......

I do that in the rexx:
cmd = 'DB2CMD DB2 -F ' SQLFILEVAR
The sql file looks like that:
CONNECT TO DBNAME
LAOD FROM........
........
CONNECT RESET

And this worked out for me... I just have to close the DB2CMD windows
after the successful run.. and that's it... :-)

Apr 11 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: les | last post by:
A Python Rexx Interface is now available to allow Python scripting to access REXX libraries and utilities. See http://www.lestec.com.au for details Regards, Les
7
by: Jeff Wang | last post by:
Hi all, Can someone help me out? I've been struggling with this for almost a week and still have no clue what's wrong. Basically I want to write a DB2 stored procedure for OS/390 in REXX. In...
0
by: Dennis B.II | last post by:
Who are REXX routines named after ?
1
by: Dennis B.II | last post by:
Who are REXX routines named after ?
2
by: dragonmsw | last post by:
I'm having a problem invoking DB2 Stored Procedures from REXX. I've written a generic SP tester where you enter the schema and name of the SP. The next panel displays the parms for the SP and...
2
by: Massimiliano Campagnoli | last post by:
What are the supported languages to write stored procedure in db2 v8.2 for linux ? Is object rexx included ?
0
by: JAW | last post by:
My account has DB2 SYSADM granted to it. I am trying to issue DB2 Subsystem commands via rexx. Error: 16.46.34 JOB04218 IEA630I OPERATOR OPRJAW0 NOW ACTIVE, SYSTEM=AGL1 , LU=...
12
by: Tony Belding | last post by:
I'm interested in using an off-the-shelf interpreted language as a user-accessible scripting language for a MUCK. I'm just not sure if I can find one that does everything I need. The MUCK must be...
2
by: Tonkuma | last post by:
I called Stored Procedure written in SQL from Object REXX on Windows like this CALL SQLEXEC 'CALL MigrateDECODE(:inString,:Converted)' CALL CHECKERR 'CALL MigrateDECODE' (CHECKERR was copied from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.