Keith, On Sun, Apr 28, 2013 at 2:21 PM, Keith Medcalf <[email protected]> wrote:
> > Exactly ... Both a=? and c=?1 will use the same parameter. With named > parameters you would do something like: > > Where a = :a and b = :b and c = :a and d = :d > > sqlite3_bind_parameter_index(stmt, ":a") -> 1 > sqlite3_bind_parameter_index(stmt, ":b") -> 2 > sqlite3_bind_parameter_index(stmt, ":d") -> 3 > > named parameters just create a mapping between unique names -> index so > you do not have to track which index number corresponds to which parameter > name. If you have lots of parameters and/or a complicated query you can > see where this greatly improves maintainability (at a small expense of > speed and code size). Many of the traditional types of SQL embeding (for > example the EXEC SQL macro in older environments) or the tcl interpreter > (for example) will automatically bind named parameters to local variables > of the same <name>. Many SQLite wrappers can map parameters the same way, > to a dictionary or to object attributes. > Thank you for confirmation. > > --- > () ascii ribbon campaign against html e-mail > /\ www.asciiribbon.org > > > > -----Original Message----- > > From: [email protected] [mailto:sqlite-users- > > [email protected]] On Behalf Of Igor Korot > > Sent: Sunday, 28 April, 2013 14:53 > > To: General Discussion of SQLite Database > > Subject: Re: [sqlite] Question about binding > > > > Hi, Keith, > > > > On Sun, Apr 28, 2013 at 12:34 PM, Keith Medcalf <[email protected]> > > wrote: > > > > > > > > http://www.sqlite.org/lang_expr.html#varparam > > > > > > They are what are called Named Parameters. You use the > > > sqlite3_bind_parameter_index to look up the index associated with a > name > > ... > > > > > > ?nnn simply means to use index nnn for that parameter. Subsequent bare > > ? > > > parameter indexes are incremented by 1 from the largest parameter index > > > thus far used. > > > > > > Ie where a= ? and b = ? and c = ?1 and d=? > > > > > > > So it means that: > > > > [pseudo-code] > > sqlite3_bind...( stmt, 1,...); > > sqlite3_bind...( stmt, 2,...); > > sqlite3_bind...( stmt, 3, ...); > > [/pseudo-code] > > > > and a and c will have 1, b - 2 and c - 3, right? > > > > Thank you. > > > > > > > Has 3 parameters. A and C use the same bind index and thus the same > > > parameter. > > > > > > --- > > > () ascii ribbon campaign against html e-mail > > > /\ www.asciiribbon.org > > > > > > > > > > -----Original Message----- > > > > From: [email protected] [mailto:sqlite-users- > > > > [email protected]] On Behalf Of Igor Korot > > > > Sent: Sunday, 28 April, 2013 13:05 > > > > To: General Discussion of SQLite Database > > > > Subject: [sqlite] Question about binding > > > > > > > > Hi, ALL, > > > > On the page http://www.sqlite.org/c3ref/bind_blob.html it says: > > > > > > > > [quote] > > > > ..... that matches one of following templates: > > > > > > > > > > > > - ? > > > > - ?NNN > > > > - :VVV > > > > - @VVV > > > > - $VVV > > > > > > > > [/quote] > > > > > > > > > > > > What is the purpose of having "NNN" and "VVV"? Are those standard? > How > > do > > > > I > > > > use those templates? > > > > > > > > Everywhere I see an examples which uses just "?" and no other 4 > > > templates. > > > > > > > > > > > > Thank you. > > > > _______________________________________________ > > > > sqlite-users mailing list > > > > [email protected] > > > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > > > > > > > > > _______________________________________________ > > > sqlite-users mailing list > > > [email protected] > > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > > _______________________________________________ > > sqlite-users mailing list > > [email protected] > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

