Cicode Programming Reference > Cicode Function Categories > SQL Functions > SQLGetField

SQLGetField

Gets field or column data from a database field. To get to a specific record in the recordset, use either the SQLNext() or SQLPrev() functions or, in case of disconnected recordsets, the nRowIndex argument.

When the hGeneral is the connection handle, the function returns information from the default recordset. When the hGeneral is the recordset handle, the function returns information from the recordset itself.

Note: All types of fields can be requested in statements, but SCADA has to convert values of the fields to MBCS 8-bit strings which is not always possible. For example either single byte database strings or numbers can be converted to MBCS 8-bit strings, multi-byte strings can be converted to MBCS (their proper presentation depends on correct setup of SCADA and OS), while blobs cannot be encoded at all.

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_").

This function can be called in the foreground or background.

Some combinations of database drivers and databases can return no name for certain classes of fields/columns, for example for aggregation queries such as "select SUM". In those cases such fields can be either explicitly named in the query itself, or accessed via a unified name in the format of "Field{ColumnNumber}" where {ColumnNumber} is the number of the requested field/column in the recordset.

Syntax

SQLGetField(hGeneral, sField, nRowIndex)

hGeneral:

The handle either to:

sField:

The name of the field or column.

nRowIndex:

If hGeneral is a connection handle and nRowindex is not equal -1, then the function returns an empty string.

Return Value

The field or column data (as a string).

The maximum length of the return data is 255 characters. If the returned data is longer than this, the function will return error 306 (can be checked by IsError() cicode function) .

Related Functions

SQLSet, SQLAppend, SQLExec, SQLGetRecordset, SQLCall, SQLGetScalar, SQLEnd, SQLNumChange, SQLNoFields, SQLNumFields, SQLFieldInfo, SQLGetField, SQLIsNullField, SQLRowCount, SQLNext, SQLPrev

Example

See SQLConnect

See Also

SQL Functions

Published June 2018