Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2010
    Posts
    5

    Question Unanswered: get data type of a column

    Hi,

    Im a newbie. I would like to know how can we get the data type of a column in c++.

    I know DESCRIBE SELECT <column name> FROM <tablename>;

    How about if writing it in c++ code?



    Thanks

  2. #2
    Join Date
    Oct 2007
    Posts
    246

    which nexcerf

    i don't know i helps or not just another way

    describe select * from tabname


    regds
    Paul

  3. #3
    Join Date
    Sep 2010
    Posts
    5
    thanks for the reply.

    i have here the code:

    *_pSession << "DESCRIBE SELECT COLNAME FROM TABNAME", into(info), now;


    my prob is I dont know what type variable 'info' will be. that will hold the results after executing that statement.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by bubbles_j View Post
    thanks for the reply.

    i have here the code:

    *_pSession << "DESCRIBE SELECT COLNAME FROM TABNAME", into(info), now;


    my prob is I dont know what type variable 'info' will be. that will hold the results after executing that statement.
    You cannot DESCRIBE an inline statement: it must refer to a prepared statement. The information you are looking for is in the SYSCAT.COLUMNS catalog view:
    Code:
    select typename, length, scale from syscat.columns
    where tabname = 'MYTABLE' and colname = 'MYCOLUMN'

  5. #5
    Join Date
    Oct 2007
    Posts
    246

    trailfes project

    yes i thought of that option too from syscat.columns but wht if user is not a superuser and everything is revoked from public, user cannot access system tables

    regds
    Paul

  6. #6
    Join Date
    Sep 2010
    Posts
    5
    I have tried to execute the statement given by n_i but it returned nothing.

  7. #7
    Join Date
    Sep 2010
    Posts
    5
    oh! n_i was right. I have missed to identify the tabschema. Thanks!

    I have one more question, is the typename a string? because i encountered an assertion error after I executed the statement.


    Here is my code:

    Code:
    *_pSession << "SELECT typename FROM syscat.columns WHERE tabschema='SAMPLE' and tabname='MYTABLE' and colname='MYCOLUMN'", into(name), now;
    where 'name' is a string variable.
    This variable 'name' is supposed to hold the result after you execute the statement.

  8. #8
    Join Date
    Sep 2010
    Posts
    5
    Sorry my bad.


    I found the error.. The code a pasted above works fine. Thanks for the help!

Posting Permissions

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