473,769 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling SYSPROC.DB2LOAD within SQL stored procedure

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.cursorload 0
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
@

Apr 7 '06 #1
1 8269
I got the stored procedure compiled by doing the following:

-- Load variable declaration
declare v_version_numbe r INTEGER default 1;
declare v_cursor_statem ent VARCHAR(32672);
declare v_load_command VARCHAR(32672);
declare v_sqlcode INTEGER default -1;
declare v_sqlmessage VARCHAR(2048) default '';
declare v_rows_read BIGINT default -1 ;
declare v_rows_skipped BIGINT default -1;
declare v_rows_loaded BIGINT default -1;
declare v_rows_rejected BIGINT default -1;
declare v_rows_deleted BIGINT default -1;
declare v_rows_committe d BIGINT default -1;
declare v_rows_part_rea d BIGINT default -1;
declare v_rows_part_rej ected BIGINT default -1;
declare v_rows_part_par titioned BIGINT default -1;
declare v_mpp_load_summ ary VARCHAR(32672) default NULL;
CALL sysproc.db2load ( v_version_numbe r, 'declare cur cursor
for SELECT * from QA.tableA',
'load from cur of cursor modified by norowwarnings insert into
PROD.tableA nonrecoverable ',
v_sqlcode, v_sqlmessage, v_rows_read, v_rows_skipped,
v_rows_loaded, v_rows_rejected , v_rows_deleted, v_rows_committe d,
v_rows_part_rea d, v_rows_part_rej ected,
v_rows_part_par titioned, v_mpp_load_summ ary) ;

Is this the correct and only way todo it ?

Thanks.

Vijay

Apr 7 '06 #2

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

Similar topics

2
8087
by: Bas | last post by:
Hi, Using SQL 2k SP3 I want to know if there's a way to retrieve the name of the database a stored proc is run in. For example: CREATE PROCEDURE HelloWorld AS
3
14204
by: mhk | last post by:
Hi, i have "req_date" column of "datetime" type in Database table besides other columns. From my Web page, i am calling the Stored Procedure with variable parameter "Search_Date" of Varchar(60) type. the value, i am passing to Stored procedure through "Search_Date" is compared to req_date column of table.
1
1548
by: AS400 Guru | last post by:
I have this stored procedure that loops through a table and updates a couple of fields. For some reason one of the fields is not being updated. If I run the same code from query analyzer, it works fine. Let me know if anyone can figure out why @lastscandate would ever be NULL. If it is null it should be equal to @maildate. The senerio that seems to fail is when no records are returned from the select statement to fill in @lastscandate....
3
6033
by: David Carver | last post by:
We are running into a problem with a Communication Link failure when calling an External Stored procedure written in ILE Cobol from an SQL UDF. When calling the stored procedure by itself and not within the UDF it runs fine, it's only when we excute the UDF that we get the communication link failure. I have setup EXTERNAL ACTION on the the UDF, the COBOL program doesn't execute any SQL statements. Here is the function and how it is...
2
6510
by: Rajat Katyal | last post by:
Hi: I prepare the statement for execution as follows: PREPARE query(text) as SELECT count(*) FROM transform_customer_billing where inv_no = $1; The problem is Iam not able to execute this prepare statement from the stored procedure defined. I added the statement to call the prepare statement is: EXECUTE query('100023'). The ERROR it prints : Function query(text) doesnot exist. Please suggest the solution for this problem.
3
4324
by: harborboy76 | last post by:
I am calling the exact same stored procedure called myprocedure from 2 different boxes from the CLP, but I'm experiencing different behaviors between them. After I was unable to get any support from IBM due to V7.1 being no longer supported, I figure someone here might be able to help. Is DB2 V7 more forgiving in the way I can call my stored procedure ? If it's defined with CHARACTER as incoming parameter, am I not required to put any...
1
1099
by: ab | last post by:
In my ASP page I'm calling a Stored Procedure on my SQL Server. No problem. But I want to check if my SP returned an error (and what kind of error) instead of the required result. To call the SP I'm using the code on http://support.microsoft.com/kb/q164485 All hints are appreciated.
5
11581
by: byahne | last post by:
We just went live today with a production SQL Server 2005 database running with our custom Java application. We are utilizing the jTDS open source driver. We migrated our existing application which was using InterBase over to SQL Server. To minimize the impact to our code, we created a stored procedure which would allow us to manage our primary key IDs (mimicing the InterBase Generator construct). Now that we have 150+ users in the...
2
2261
by: adukuri | last post by:
Hi, I am new to jsp coding and I need some help in coding. 1. Writing to a text file from a result set. need to open a new txt file on a unix box and store it. 2. Paging. To generate mulitple -pages based on the records. 3. passing an resultset as an input to a oracle procedure.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.