MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sqlcode error -803 while insert

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Rama_Prayaga
Beginner


Joined: 20 May 2003
Posts: 45
Topics: 15

PostPosted: Wed Feb 23, 2005 8:19 am    Post subject: Sqlcode error -803 while insert Reply with quote

Hello,

I have unique Index in a table, build in set of 7 coulumns.Primary key is not the part of the this unique index.

I have to insert a new row.

The the following is the steps I follow.

Code:
1) read the table.if sqlcode is 0 then fetch the row.
2) if sqlcode is 100 , then insert a new row.


But while insert I am facing a problem.There is also another similer online program which insert the rows in the same table.So I am getting Sqlcode of -803.

So I have to make the changes to my program such that

Code:
---> i want to check whether -803 is caused because of duplicate Unique index or duplicate key.How can I check that.

---> if it is because of duplicate primary key then I will create a new key.

---> if the error is because of Duplication of unique index then I will read the table.

kindly ,Please let me know how to proceed further

Regards,
Rama Krishna Prayaga
Back to top
View user's profile Send private message Yahoo Messenger
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Wed Feb 23, 2005 8:40 am    Post subject: Reply with quote

Rama_Prayaga,
Why would you have two sets of 'Unique' index ? A table is normally associated with only one unique index 7 that may or may not be a primary key. A primary key in itself is unique. Though things can be manipulated technically, I would suggest a second look at the table structure - all index(s) and how they are defined. If still needed, check the SQLCA/SQLDA, the voilation on which index happened is also provided, you may interpret it know where the failure was. Thanks
Back to top
View user's profile Send private message
Rama_Prayaga
Beginner


Joined: 20 May 2003
Posts: 45
Topics: 15

PostPosted: Wed Feb 23, 2005 9:16 am    Post subject: Reply with quote

Hi Suresh,

Thanks for your reply,I think I should elobrate my requirement a bit.

See, Primary key is build in the program by giving Max rows + 1,Since this key is build in another online program as well in similar fashion. There can be a dupicate error.

Now if the problem is with the Primary-key, I can create a new key by giving Max rows +1 again and insert the row.

But if it is the duplicate problem with Unique index (its is created on a set of seven columns) , then I cannot insert that (i dont have to).

I hope i put my problem cleary this time Confused

Regards
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Feb 23, 2005 9:22 am    Post subject: Reply with quote

Rama_Prayaga,


The simplest way to handle such scenario's is to select before you insert a row.

1. select to see if it is a duplicate key
2. Select to see if it is the unique index defined on the seven columns.
Code:

if sqlcode from 2nd select  = 0
   skip insert
else
   increment the max key
   insert the row
end-if

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rama_Prayaga
Beginner


Joined: 20 May 2003
Posts: 45
Topics: 15

PostPosted: Thu Feb 24, 2005 9:27 am    Post subject: Reply with quote

kolusu,

Thank you for your suggestion. I have adapted you suggestion in the program.

I was thinking if SQLSTATE could help me.But I was not sure of it.

What is use of SQLSTATE .I thought it will sub classify the the SQLCODE.Please correct me I am wrong

Rama
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Feb 24, 2005 9:44 am    Post subject: Reply with quote

Rama_Prayaga,

Check this link for a detailed explanation of SQLSTATE

SQLSTATE

Using SQLSTATE values

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group