473,386 Members | 1,908 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,386 software developers and data experts.

Sql storedprocedure return no error code

1
Hi All,

I am very new to DB2 programming. I have written a SQL stored procedure and called it from C# . The program is working but it is not returning the error code and sqlstate code. If i comment out all the code except the DELETE SQL statement it gives error with code "SQL0532" in my program side.
Why the EXIT handler is not invoking? OR Why it is not returning values through OUT parameters.?

Looking forward to hear from you. My stored procedure is given below.I am using iSeries Navigator for writing the the following code so some auto generated is also there.(line 5-17)

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE TYKDFLIB.SP_DELETE ( 
  2.     IN PID CHAR(20) , 
  3.     OUT PSQLSTATE CHAR (5),
  4.     OUT PSQLCODE INTEGER ) 
  5.     LANGUAGE SQL 
  6.     SPECIFIC TYKDFLIB.SP_DELETE 
  7.     NOT DETERMINISTIC 
  8.     MODIFIES SQL DATA 
  9.     CALLED ON NULL INPUT 
  10.     SET OPTION  ALWBLK = *ALLREAD , 
  11.     ALWCPYDTA = *OPTIMIZE , 
  12.     COMMIT = *NONE , 
  13.     DECRESULT = (31, 31, 00) , 
  14.     DFTRDBCOL = *NONE , 
  15.     DYNDFTCOL = *NO , 
  16.     DYNUSRPRF = *USER , 
  17.     SRTSEQ = *HEX   
  18.     BEGIN 
  19.  
  20.         DECLARE SQLSTATE CHAR ( 5 ) DEFAULT '00000' ;
  21.           DECLARE SQLCODE INT DEFAULT 0 ;  
  22.  
  23.         DECLARE EXIT HANDLER FOR SQLEXCEPTION  
  24.  
  25.         SELECT SQLSTATE , SQLCODE  
  26.         INTO PSQLSTATE , PSQLCODE  
  27.         FROM SYSIBM . SYSDUMMY1 ; 
  28.  
  29.         DELETE FROM TYKDFLIB . TEST01 WHERE ID = PID ;    
  30.  
  31.         VALUES ( SQLSTATE , SQLCODE )  
  32.         INTO PSQLSTATE , PSQLCODE ;
  33.  
  34.         END  ;
  35.  

Thanks in advance!
Mar 17 '10 #1
1 3920
The following Stored procedure is working fine for me.

CREATE PROCEDURE TYKDFLIB.SP_DELETE (
IN PID CHAR(20) ,
OUT PSQLSTATE CHAR (5),
OUT PSQLCODE INTEGER )
LANGUAGE SQL
SPECIFIC TYKDFLIB.SP_DELETE
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
BEGIN

DECLARE SQLSTATE CHAR ( 5 ) DEFAULT '00000' ;
DECLARE SQLCODE INT DEFAULT 0 ;

DECLARE EXIT HANDLER FOR SQLEXCEPTION

SELECT SQLSTATE , SQLCODE
INTO PSQLSTATE , PSQLCODE
FROM SYSIBM . SYSDUMMY1 ;

VALUES ( SQLSTATE , SQLCODE )
INTO PSQLSTATE , PSQLCODE ;

END
Apr 22 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: PeteZ | last post by:
what using . . . . statement do I need to get this value (CommandType.StoredProcedure) defined ? even when I have defined the using statements: using System; using System.Data.SqlClient;...
4
by: Brian Parker | last post by:
I've been banging my head on this for hours and it's something that should be very very easy. I have a Stored Procedure in a MS-SQL 2000 server that returns a Varchar(40) and I want to grab that...
0
by: Amol | last post by:
Hello, I am developing an apllication in which i want to change the values of datagrid checkbox column according to parameter passed to the query. But the problem is that, at first time when i...
9
by: Frank | last post by:
Hi, imagine there's a WEB application reading data from an Oracle database to visualize in using DataGrids in the clients browser. Yes, sounds simple, just create OracleConnection + OracleCommand...
1
by: phanimadhav | last post by:
Hello friends,I have one small doubt.Acually myclient asking by using tableAdapetr call the MySQL procedures.How to call the MySQL storedprocedure in TableAdapter.In the Table adapter contain one...
3
by: gopi2ks | last post by:
Dear All, I have one stored procedure like sp_insertEmployee Employee Table Fileds Eno int pk, ename varchar(100), designation varchar
2
by: Tony Johansson | last post by:
Hello! I just wonder when you use StoredProcedure will you then use DataSet ? In the example that I have seen is the DataSet not used is this normal ? //Tony
1
by: Tony Johansson | last post by:
Hello! Is it possible to use a StoredProcedure when you have SqlDataAdapter or is it only possible when you have SqlCommand like SqlCommand thisCommand = myConnection.CreateCommand;...
2
by: gabosom | last post by:
Hi! I've been breaking my head trying to get the output variables from my Stored Procedure. This is my SP code CREATE PROCEDURE GetKitchenOrderDetail( @idService int, --outPut Variables ...
1
by: thesti | last post by:
hi, is there anyway to know whether a INSERT/UPDATE/DELETE stored procedured was executed successfully? for example, if i have the following StoredProcedure: create procedure...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.