dbExecute

Top  Previous  Next

Syntax

INT = dbExecute(hstmt as INT)

Description

Executes a prepared statement, using the current values of the parameter marker variables if any parameter markers exist in the statement.

Parameters

hstmt - Statement handle returned by dbPrepareSQL.

Return value

TRUE if statement was successfully executed. FALSE if there was an error.

Remarks

Prepared statements are used to perform many duplicate  updates or inserts into a database table. Using a prepared statement allows simply updating the bound parameters and calling dbExecute for each iteration. The main advantage over direct execution with dbExecSQL is speed of updates and insertions.

See Also: dbPrepareSQL, dbFreeSQL

Example usage

hstmt = dbPrepareSQL(pdb,"INSERT INTO Addresses (FirstName,LastName,Address) VALUES(?,?,?)")
IF hstmt
    dbBindParameter(hstmt,1,first,255)
    dbBindParameter(hstmt,2,last,255)
    dbBindParameter(hstmt,3,street,255)
    'after the variables are bound you can insert as many records as needed with one statement
    first = "Lisa"
    last = "Jones"
    street = "123 Niagara"
    dbExecute(hstmt)
    '
    first = "Tammy"
    last = "Miller"
    street = "123 America St"
    dbExecute(hstmt)
    '
dbFreeSQL(hstmt)
ENDIF