Using Bind Variables [message #205722] |
Mon, 27 November 2006 04:33 |
Anand Ramaswamy
Messages: 111 Registered: January 2005
|
Senior Member |
|
|
Hi All,
In almost all books including Tom Kyte, everyone has emphasized on the usage of Bind Variables.
For example:
It is not advised to use
select * from emp where empno=123;
However it is advised to use
select * from emp where empno = :empno;
However in a practical scenario consider a web application, I would use a connection object say db, a recordset say rs and variables say empNo and strQry.
Example:
empNo = 123;
strQry = "SELECT * FROM EMP WHERE EMPNO ="&empNo
rs.open strQry, db
Using this recordset (rs), I'll perform further operations.
I would like to know how the query will be treated? A query with a bind variable, or a query without a bind variable.
Thanks in advance
Anand
|
|
|
|
|
Re: Using Bind Variables [message #205757 is a reply to message #205722] |
Mon, 27 November 2006 07:06 |
michael_bialik
Messages: 621 Registered: July 2006
|
Senior Member |
|
|
Try following:
With cmd
.CommandText = "SELECT * FROM EMP WHERE EMP_ID = ?"
.CommandType = adCmdText
.ActiveConnection = cnn
.Parameters.Append .CreateParameter(, adDouble, adParamInput )
End With
cmd(0) = 123
SET rs = cmd.execute
HTH
|
|
|
|