Hi:
How can one call SYSPROC.DB2LOAD procedure within a SQL stored
procedure.
I get the following error:
DB21034E The command was processed as an SQL statement because it was
not a valid Command Line Processor command. During SQL processing it
returned: SQL0418N A statement contains a use of a parameter marker
that is not valid. LINE NUMBER=48. SQLSTATE=42610.
Thanks for your help.
Vijay
The code is given below:
create procedure prod.cursorload (out p_status varchar(300))
language sql
specific prod.cursorload0
modifies sql data
-- compound statements begin here
cs_0: begin
-- variable declaration
declare v_return integer default -1;
declare v_statusmsg varchar(300) default 'Procedure Error Terminated';
declare v_sqlstate char(5) default '00000';
declare sqlstate char(5) default '00000';
-- handler declaration
cs_0_0: begin
declare continue handler for not found
set v_sqlstate = '00000';
declare exit handler for sqlexception, sqlwarning
begin
set v_sqlstate = sqlstate;
set p_status = v_sqlstate || ' ' || v_sp_name || ' ' ||
v_statusmsg;
end;
-- Load table
CALL sysproc.db2load ( 1, 'declare cur cursor for SELECT * from
stage.tableA',
'load from cur of cursor modified by norowwarnings insert into
prod.tableA nonrecoverable ',
?, '', ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL) ;
set v_return = 0;
set p_status = v_sqlstate || ' ' || v_sp_name || ' Normal
completion';
end cs_0_0;
return v_return;
end cs_0
@ |