If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > help needed in finding primary key info of a table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-13-03, 00:08
kangan kangan is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
help needed in finding primary key info of a table

Hi,
I am new to Db2, and I read the Db2 documentation available in the websites and generated a database and a table with primary keys in it. I was able to do select, delete, insert etc using DB2 CLI. I used Microsoft Visual C++ 6.0 for the same. But when I was trying to get the Primary key info for the table, I was not able to do that. The function call SQLPrimarykkeys was successfull. But SQLFetch function returned a NO Data Found value. I need pointers as to where I might be going wrong.
I have another question too. When I tried to access a table created by another user Using DB2 CLI, It gave me an error. I had to do an alias to workaround that problem, is there any generic solution to that problem.
-thanks
Kangan
Reply With Quote
  #2 (permalink)  
Old 11-13-03, 03:33
jsander jsander is offline
Registered User
 
Join Date: Apr 2003
Posts: 191
Re: help needed in finding primary key info of a table

Hi,

pretty weird. Visual C++ 6.0 is a couple of years old, if I remember right. What version of DB2 are you on? I have no knowledge about MFC, could be libraries are incompatible?

Johann

Quote:
Originally posted by kangan
Hi,
I am new to Db2, and I read the Db2 documentation available in the websites and generated a database and a table with primary keys in it. I was able to do select, delete, insert etc using DB2 CLI. I used Microsoft Visual C++ 6.0 for the same. But when I was trying to get the Primary key info for the table, I was not able to do that. The function call SQLPrimarykkeys was successfull. But SQLFetch function returned a NO Data Found value. I need pointers as to where I might be going wrong.
I have another question too. When I tried to access a table created by another user Using DB2 CLI, It gave me an error. I had to do an alias to workaround that problem, is there any generic solution to that problem.
-thanks
Kangan
Reply With Quote
  #3 (permalink)  
Old 11-13-03, 15:07
kangan kangan is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
Hi,
I am using DB2 V8.1. I am still not able to fix the problem. Any pointers would be appreciated.
-Thanks
Kangan
Reply With Quote
  #4 (permalink)  
Old 11-14-03, 12:35
kangan kangan is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
Hi,
I found the solution. The table name has to be in Caps. If u would go to the syscolumns table and look at each row, with keyseq >0, that gives you the primary keys present in the Database. If u want to query the primary keys in the table you want, you have to convert the table to caps and then do it. Instead of this, if u want to call the SQLPrimaryKeys function, then if the table name is going to be in Caps, then there wont be any problem.
-Kangan
__________________
kr
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On