bind-parameter

Function

Package: dbi

Arguments: param-num obj type width &key db hstmt

This function creates a binding for a parameter for a parameterized sql statement.

A binding is the assigning of a block of memory to hold the value of a given parameter. Whenever a parameterized sql statement is executed, ODBC looks in the bindings and uses the current value found there. param-num is the index of the parameter to be bound. The first parameter is number 1 (not 0). obj is the object to bind to the parameter. If obj is nil then an object will be allocated. type is the type of the value stored in the object. It can be :long or :int (treated the same), or :float or :double (treated the same) or :char or :varchar. If the type is :char or :varchar then the width specifies the maximum number of characters in the object.

The binding is associated with a particular statement handle for a particular database connection. If hstmt is true then it is that statement handle. Otherwise if db is true then its default statement handle is used. If db is nil then the value of *default-database* is the database connection whose statement handle is used.

Normally in a call to bind-parameter the value of obj is nil which calls for bind-parameter to allocate an object of the appropriate type and return it as the result of the call. If obj is true then it should be an object allocated by a previous call to bind-parameter for the same type and width. The objects allocated by bind-parameter are foreign objects of allocation type :foreign-static-gc. It is the program's responsibility to keep pointers to these bound objects so that they aren't garbage collected before they are used for the last time.

The example of using bind-parameter in Binding input parameters in aodbc.htm shows what these bound objects look like from the Lisp perspective.

See aodbc.htm for more information on Allegro ODBC.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.