wwsql::AddParameter

Used to set named parameters to be passed into SQL statements.

Note that must be defined in the same order as they appear in the SQL statement as native FoxPro parameters are injected as ? parameters, and ADO parameters are always treated sequentially.

For SQL Passthrough (wwSQL) this method has extra overhead - use FoxPro's native ? parameter syntax instead. For ADO, this method is more efficient. It works for mechanisms so if you want to create universally usable code use this method.

o.wwsql.AddParameter(lvValue,lcName,
                     lcDirection, lnAdoType,
                     lnSize,lnPrecision)

Return Value

nothing

Parameters

lvValue
The Value for the parameter

lcName
The name of the parameter

lcDirection
IN OUT

lnAdoType
Optional - The ADO type when using wwAdoSql ignored in wwSql. If no type is specified wwAdoSql will take a best guess�based on the value's type.

These values are:

adEmpty                                           0
adTinyInt                                         16
adSmallInt                                        2
adInteger                                         3
adBigInt                                          20
adUnsignedTinyInt                                 17
adUnsignedSmallInt                                18
adUnsignedInt                                     19
adUnsignedBigInt                                  21
adSingle                                          4
adDouble                                          5
adCurrency                                        6
adDecimal                                         14
adNumeric                                         131
adBoolean                                         11
adError                                           10
adUserDefined                                     132
adVariant                                         12
adIDispatch                                       9
adIUnknown                                        13
adGUID                                            72
adDate                                            7
adDBDate                                          133
adDBTime                                          134
adDBTimeStamp                                     135
adBSTR                                            8
adChar                                            129
adVarChar                                         200
adLongVarChar                                     201
adWChar                                           130
adVarWChar                                        202
adLongVarWChar                                    203
adBinary                                          128
adVarBinary                                       204
adLongVarBinary                                   205
adChapter                                         136
adFileTime                                        64
adDBFileTime                                      137
adPropVariant                                     138
adVarNumeric                                      139

lnSize
Optional - size for the parameter. If you don't specify a default size is used. Note adDouble is used for numerics by default if omitted.

lnPrecision
Optional - precision for numeric parameters.

Remarks

Input parameters are automatically cleared the first time this method is called or after execution of a query. This ensures each query automatically starts with a clean parameter list and you don't have to explicitly keep clearing parameters. To override and keep parameters you can set lParameterReset = .F. before executing the first AddParameter() call on subsequent Execute commands.

wwAdoSql Specific Notes

The following notes do not apply to wwSql, only to wwAdoSql.

If wwAdoSql.nCodePage = 65001 (UTF-8) string parameters are passed and returned using Unicode. Otherwise string parameters are passed using plain VarChar or Text data.

By default all parameters are passed as VarChar(8000) when using Ansi text, and nVarChar(4000) when Unicode is used. If you specifically need to pass Text or nText explicitly you must override the type with 201 and 203 respectively.

Note, passing text/ntext output parameters is not working with ADO for reasons unknown. ADO will not pass the data to SQL Server but give an Unknown Error exception. Since it's not really possible to assign Text/nText data to a variable anyway, this point is kind of moot. However, the SQL Server docs do mention that it is supported. If you're returning Text/nText data that can't fit into VarChar/nVarChar you should return cursors rather than result values.

Example

oSQL = CREATEOBJECT("wwSql")
oSql.Connect("database=Classifieds")
oSql.Addparameter(REPL("123 ",3000),"desc")

*** Use desc variable in the passthrough statement
? oSql.Executenonquery("update entries set description=?desc where id=8895")

See also:

Class wwsql

© West Wind Technologies, 1996-2024 • Updated: 04/18/22
Comment or report problem with topic