Skip to content

SQLColumnValue - cSQLStatement

Get a column value.

Type: Function
Return Data Type: String

Parameters

Parameter Type Description
iCol Integer Number of the column the value of which to get (1-based)

Syntax

Function SQLColumnValue Integer iCol Returns String

Call Example

Get SQLColumnValue iCol to StringVariable

Description

Returns the value of the specified column. The column number must be passed. Column numbers are 1-based. If an invalid column number is passed, an error will be generated.

Sample

Handle hoSQLMngr hdbc hstmt
Integer iFetchResult
String sName sState

Object oSQLHandler Is A cSQLHandleManager
    Move Self To hoSQLMngr
End_Object

Open Customer
Get SQLFileConnect Of hoSQLMngr Customer.File_number To hdbc
Get SQLOpen Of hdbc To hstmt
Send SQLExecDirect Of hstmt "select name, state from customer"
Repeat
    Get SQLFetch Of hstmt To iFetchResult
    If (iFetchResult <> 0) Begin
        Get SQLColumnValue Of hstmt 1 To sName
        Get SQLColumnValue Of hstmt 2 To sState
        Showln sName ", " sState
    End
Until (iFetchResult = 0)

Send SQLClose Of hstmt
Send SQLDisconnect Of hdbc

Use SQLDateToDFDate to convert SQL dates to the DataFlex date data type. Use SQLGetData to retrieve data that is too large for SQLColumnValue (e.g. for varchar(max) and text type columns).

Return Value

Returns a column value.