Skip to content

SQLExecDirect - cSQLStatement

This procedure combines the SQLPrepare and SQLExecute.

Type: Procedure

Parameters

Parameter Type Description
sStatement String SQL statement to execute

Syntax

Procedure SQLExecDirect String sStatement

Call Example

Send SQLExecDirect sStatement

Description

Execute the passed statement. Direct execution is intended for statements that are only executed once. If you need to execute a statement more than once, use the SQLPrepare, SQLExecute messages.

See Parameterized Queries for more information on parametrized queries and prepared execution.

Resets piLastArgument to 0.

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
    End
Until (iFetchResult = 0)

Send SQLClose of hstmt
Send SQLDisconnect of hdbc