コード例 #1
0
ファイル: SQLDescribeCol.c プロジェクト: Azure/unixODBC-MSSQL
SQLRETURN CLDescribeCol( SQLHSTMT statement_handle,
           SQLUSMALLINT column_number,
           SQLCHAR *column_name,
           SQLSMALLINT buffer_length,
           SQLSMALLINT *name_length,
           SQLSMALLINT *data_type,
           SQLULEN *column_size,
           SQLSMALLINT *decimal_digits,
           SQLSMALLINT *nullable )
{
    CLHSTMT cl_statement = (CLHSTMT) statement_handle; 

    return SQLDESCRIBECOL( cl_statement -> cl_connection,
           cl_statement -> driver_stmt,
           column_number,
           column_name,
           buffer_length,
           name_length,
           data_type,
           column_size,
           decimal_digits,
           nullable );
}
コード例 #2
0
ファイル: SQLExecDirect.c プロジェクト: capensis/canopsis-edc
SQLRETURN get_column_names( CLHSTMT cl_statement )
{
    int i;
    char cname[ 256 ];

    /*
     * already done ?
     */

    if ( cl_statement -> column_names )
    {
        return SQL_SUCCESS;
    }

    /*
     * get the names of all the columns
     */

    cl_statement -> column_names = malloc( sizeof(char *) 
            * cl_statement -> column_count );

    cl_statement -> data_type = malloc( sizeof( SQLSMALLINT ) 
            * cl_statement -> column_count );

    cl_statement -> column_size = malloc( sizeof( SQLULEN ) 
            * cl_statement -> column_count );

    cl_statement -> decimal_digits = malloc( sizeof( SQLSMALLINT ) 
            * cl_statement -> column_count );

    for ( i = 1; i <= cl_statement -> column_count; i ++ )
    {
        SQLRETURN ret;
    
        if ( !CHECK_SQLDESCRIBECOL( cl_statement -> cl_connection ))
        {
            cl_statement -> cl_connection -> dh.__post_internal_error( &cl_statement -> 
                    dm_statement -> error,
                    ERROR_01000, "Driver does not support SQLDescribeCol",
                    cl_statement -> dm_statement -> connection ->
                        environment -> requested_version );

            return SQL_ERROR;
        }
        ret = SQLDESCRIBECOL( cl_statement -> cl_connection,
                cl_statement -> driver_stmt,
                i,
                cname, 
                sizeof( cname ),
                NULL,
                &cl_statement -> data_type[ i - 1 ], 
                &cl_statement -> column_size[ i - 1 ],
                &cl_statement -> decimal_digits[ i - 1 ],
                NULL );

        if ( !SQL_SUCCEEDED( ret ))
        {
            cl_statement -> cl_connection -> dh.__post_internal_error( &cl_statement -> 
                    dm_statement -> error,
                    ERROR_01000, "SQLDescribeCol failed in driver",
                    cl_statement -> dm_statement -> connection ->
                        environment -> requested_version );

            return SQL_ERROR;
        }

        cl_statement -> column_names[ i - 1 ] = strdup( cname );
    }

    return SQL_SUCCESS;
}