How to get output for a query - Programmer

This is a discussion on How to get output for a query - Programmer ; HI SELECT DATA_TYPE FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = 'NOTES' AND COLUMN_NAME = 'NOTE' The above query will return the column data type as string. When I tried it in sql plus it works fine. However CDatabase::ExecuteSql() wont return any output. ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: How to get output for a query

  1. How to get output for a query

    HI

    SELECT DATA_TYPE FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = 'NOTES' AND
    COLUMN_NAME = 'NOTE'

    The above query will return the column data type as string. When I
    tried it in sql plus it works fine. However CDatabase::ExecuteSql()
    wont return any output. Is there a simple way to execute the query in
    mfc and get the result?
    Thanks for you help.

    -krish

  2. Re: How to get output for a query

    In article <3c19ac7a.0404302224.36b1749c@posting.google.com>,
    mask_0072001@hotmail.com (mask) wrote:

    > HI
    >
    > SELECT DATA_TYPE FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = 'NOTES' AND
    > COLUMN_NAME = 'NOTE'
    >
    > The above query will return the column data type as string. When I
    > tried it in sql plus it works fine. However CDatabase::ExecuteSql()
    > wont return any output. Is there a simple way to execute the query in
    > mfc and get the result?


    You use a CRecordset.

    You call its Open() member function with:

    myset.Open(AFX_DB_USE_DEFAULT_TYPE, "SELECT DATA_TYPE FROM
    ALL_TAB_COLUMNS WHERE TABLE_NAME = 'NOTES' AND COLUMN_NAME = 'NOTE'");

    then, you retrieve the values with a loop like:
    int i = 0;

    while( ! myset.IsEOF()){
    if( ! myset.IsFieldNull(&myset.m_NOTE)){
    printf("%d: %s\n", ++i, (const char *) myset.m_NOTE);
    }
    myset.MoveNext();
    }
    myset.close();

+ Reply to Thread