Skip to Main Content Skip to Search
Product Documentation

columnnames - Retrieve names of columns in fetched data set

Syntax

FIELDSTRING = columnnames(CURSOR)
FIELDSTRING = columnnames(CURSOR,BCELLARRAY)

Description

FIELDSTRING = columnnames(CURSOR) returns the column names of the data selected from a database table. The column names are enclosed in quotes and separated by commas. (The columnnames function is not supported for a cursor object returned by the fetchmulti function.)

FIELDSTRING = columnnames(CURSOR,BCELLARRAY) returns the column names as a cell array of strings when BCELLARRAY is set to true.

Examples

  1. Run a SQL query to return all columns from the Microsoft Access Northwind database employees table:

    sql = 'select * from employees'
    cursor = exec(connection, sql)
    cursor = fetch(cursor)
  2. Use columnnames to retrieve all column names for the selected columns:

    fieldString = columnnames(cursor)
    fieldString = 
    'EmployeeID','LastName','FirstName','Title',
    'TitleOfCourtesy','BirthDate','HireDate','Address',
    'City','Region','PostalCode','Country','HomePhone',
    

See Also

attr | cols | columnprivileges | columns | cursor.fetch | get | width

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS