Skip to content

SQLSetParameter - cSQLStatement

Pass a parameter for a parameterized query or stored procedure

Type: Procedure

Parameters

Parameter Type Description
iParamNum Integer Parameter number
sParamValue String Parameter value
iParamType Integer

Syntax

Procedure SQLSetParameter Integer iParamNum String sParamValue Integer iParamType

Call Example

Send SQLSetParameter iParamNum sParamValue iParamType

Description

SQLSetParameter is used to pass parameters for a parameterized query.

Parameters are numbered from 1 in the order the parameter markers (?) appear in the SQL Query.

Parameter values can be passed as ASCII, String, Number, Date, Datetime, or Time.

Types other than String will be converted to the correct format to pass to the database.

Sample

Pass a Date parameter:

Date dParamDate
Integer iParamNum
Handle hoStatement

Move 2 to iParamNum
Move (DateSet(2015, 12, 25)) to dParamDate
Send SqlSetParameter of hoStatement iParamNum dParamDate typeDate

Sample

Pass a DateTime parameter:

DateTime dtToday
Integer iParamNum
Handle hoStatement

Move 3 to iParamNum
Move (CurrentDateTime()) to dtToday
Send SqlSetParameter of hoStatement iParamNum dtToday typeDateTime

All parameters of a SQLQuery must be passed. If more parameters are set than there are parameter markers, the additional parameters will be ignored.

Parameters remain set after a SQLExecute. If a parameter is not set to a different value after SQLExecute, the next SQLExecute will use the same parameter value.

Parameters are discarded when closing the statement with SQLClose.