SQLFieldInfo
Gets information about the fields or columns selected by a SQL query. The function returns the name and width of the specified field. If you call the function within a loop, you can return the names and sizes of all the fields in the database.
Keywords such as "DATE", "TIME", and "DESC" cannot be used as field names by some database systems. To use fields with these names, you need to append underscores to the names (for example, "TIME_", "DATE_", "DESC_").
Syntax
SQLFieldInfo(hSQL, hField, sName, Width)
hSQL:
The handle to the SQL connection, returned from the SQLConnect() function. The SQL connection handle identifies the table where details of the associated SQL connection are stored.
hField:
The field (or column) handle, indicating the position of the field in the database.
sName:
A string variable in which the function stores the field name.
Width:
An integer variable in which the function stores the field width.
Return Value
0 (zero) if successful, otherwise an error number is returned. (For details of the 307 error code, call the SQLErrMsg function).
Related Functions
SQLBeginTran, SQLCommit, SQLConnect, SQLDisconnect, SQLEnd, SQLErrMsg, SQLExec, SQLGetField, SQLInfo, SQLNext, SQLNoFields, SQLNumChange, SQLRollBack, SQLTraceOff, SQLTraceOn
Example
! Lists all fields in the Employee database
FUNCTION
ListFields()
INT hSQL;
STRING sField;
INT Count;
INT Width;
INT Index;
SQLTraceOn("C:\DATA\TRACE.LOG");
hSQL = SQLConnect("DRV=QEDBF");
SQLExec(hSQL, "SELECT * FROM C:\DATA\EMPLOYEE");
Count = SQLNoFields(hSQL);
Index = 0;
WHILE Index < COUNT DO
SQLFieldInfo(hSQL,Index,sField,Width);
..
END
SQLEnd(hSQL);
SQLDisconnect(hSQL);
SQLTraceOff();
END
See Also