Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

sql error -530

 
   Database Forums (Home) -> DB2 RSS
Next:  Help needed!!!!! SQL server 2005 configuration  
Author Message
Wojtek Kusch

External


Since: Aug 16, 2007
Posts: 1



(Msg. 1) Posted: Thu Aug 16, 2007 3:56 pm
Post subject: sql error -530
Archived from groups: comp>databases>ibm-db2 (more info?)

Ist this possible to get the causing column for a sql error -530
(foreign key) in an insert command?

What I mean:

evaluate sqlcode
if -530
if causing_column = "Model"
....
end if
if causing_column = "Group"
....
end if
end if
end evaluate


Thanks for help!
Wojtek Kusch

 >> Stay informed about: sql error -530 
Back to top
Login to vote
Knut Stolze

External


Since: Jun 23, 2003
Posts: 497



(Msg. 2) Posted: Fri Aug 17, 2007 6:55 am
Post subject: Re: sql error -530 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Wojtek Kusch wrote:

> Ist this possible to get the causing column for a sql error -530
> (foreign key) in an insert command?
>
> What I mean:
>
> evaluate sqlcode
> if -530
> if causing_column = "Model"
> ....
> end if
> if causing_column = "Group"
> ....
> end if
> end if
> end evaluate

The message gives you the name of the constraint violated. So you could look
up in the DB2 catalog which column(s) this constraint is defined on. If
all your FKs are just on a single column, it works that way. If you have
multi-column FKs, then DB2 doesn't tell you the name of the specific column
or columns that failed - because you have to take all columns of the
constraint into consideration. For example if you have this:

CREATE TABLE p ( c1 INT NOT NULL, c2 INT NOT NULL, PRIMARY KEY(c1, c2) )@
INSERT INTO p VALUES (1, 2), (2, 1)@

C1 C2
--- ---
1 2
2 1

Now you want to insert into the referencing table C:

CREATE TABLE c ( c1 INT, c2 INT, FOREIGN KEY(c1, c2) REFERENCES p )@
INSERT INTO c VALUE (1, 1)@

This INSERT statement fails with -530 (SQL0530). But which column is at
fault - C1 or C2? So you have to look at all columns together.

Btw, the following query will return all columns in a foreign key:

SELECT colname
FROM syscat.keycoluse
WHERE ( tabschema, tabname ) = ( ..., ... ) AND
constname = '...'


--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany

 >> Stay informed about: sql error -530 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
DB2 error on AIX - i am working with db2 8.1 and when i log on as db2inst1 and issue the comand db2 for db2 prompt it gives me following error DB21015E The Command Line Processor backend process request queue or input queue was not created within the timeout period. db...

DB2 Error - Exception EDBEngineError in module Cserv.exe at 0013E2C8. General SQL error. [IBM][CLI Driver][DB2/NT]SQL0727N An error occurred during implicit system action type "1". Information returned for the error includes SQLCODE "-101", SQLST...

TCP/IP Error, rc1=22 - ENVIRONMENT: ________________________________________________________ "Server 1" = DB2 UDB ESE 7.1 FP7 on AIX 5.1 "Server 2" = DB2 UDB ESE 8.1 FP2 on AIX 5.1 ________________________________________________________ SCENARIO:..

SQL error - i get this error SQL30020N when selecting data from a table . I altered this table earlier today when i do it a select * from the table query runs OK, but when i join this table with 10 other tables (in a scheduled job) i get this error. The job has bee...

what is this error ? - I see a lot of dump file with this kind of messages on the db2dump path, what is this ? I looked up SQL0820N, it says the is some connector exceeding its limit. How can I find out what the limit is and how I can change it ? Any help will be appreciated ...
   Database Forums (Home) -> DB2 All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]