Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    17

    Unanswered: 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

  2. #2
    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

    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

  3. #3
    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

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •