dbExecSQL

Top  Previous  Next

Syntax

HANDLE = dbExecSQL(pConnection as POINTER,statement as STRING)

Description

Immediately executes an SQL statement for the database.

Parameters

pConnection - A pointer to a database returned by dbConnect or dbConnectDSN.

statement - The SQL statement to execute

Return value

A handle to the executed SQL statement or NULL if a statement handle could not be allocated.

Remarks

Use dbGetErrorCode or dbGetErrorText to determine whether the statement was successfully executed. The application can include one or more parameter markers in the SQL statement. To include a parameter marker, the application embeds a question mark (?) into the SQL statement at the appropriate position. When finished with the returned statement handle the application must free it with dbFreeSQL.

See Also: dbFreeSQL, dbPrepareSQL, dbExecute, dbFreeSQL

Example usage

hstmt = dbExecSQL(pdb,"SELECT * FROM Addresses WHERE FirstName = 'John'")
error = dbGetErrorCode(hstmt)
IF LEN(error)
    PRINT
    PRINT "Error Code: ", error
    PRINT "Error Text: ", dbGetErrorText(hstmt)
    PRINT
ENDIF