From: cberthu on
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

From: Mark A on
<cberthu(a)gmail.com> wrote in message
news:1176187012.300622.143260(a)n76g2000hsh.googlegroups.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.


From: cberthu on
On Apr 10, 10:12 am, "Mark A" <nob...(a)nowhere.com> wrote:
> <cber...(a)gmail.com> wrote in message
>
> news:1176187012.300622.143260(a)n76g2000hsh.googlegroups.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??

From: mike on
On Apr 10, 7:36 am, "cber...(a)gmail.com" <cber...(a)gmail.com> wrote:
> 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.


From: cberthu on
<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.....