[PYTHON DB-SIG] RE: Looking for examples of oracledb usage

Greg Stein gstein@microsoft.com
Mon, 21 Apr 1997 18:02:20 -0700


The bind variables are numbered using 1-based values. As I recall, there
is no limit to the number of bind variables you may specify, but Jim
Fulton would be the expert here for the oracledb module.

My advice: try it and see :-)

-g

	-----Original Message-----
	From:	Harold Poskanzer [SMTP:hmp@infoseek.com]
	Sent:	Monday, April 21, 1997 3:26 PM
	To:	db-sig@python.org
	Subject:	Re: [PYTHON DB-SIG] RE: Looking for examples of
oracledb usage 

	Would you believe I was wondering what the oracledbmodule bind
variable syntax 
	was the night before I got this email?

	I have one question, though:  I assume I can do :0 through :9
easily, but how 
	do I do more than 10 bind variables?

	-H


=====================================================================
	Harold Poskanzer                                    Software
Engineer
	Infoseek Corporation
hmp@infoseek.com
	2620 Augustine Dr #250                            Phone:
408/567-2741
	Santa Clara, CA 95054
http://www.infoseek.com/

---------------------------------------------------------------------
	                Proof of Intelligent Life on the Net

	> The :N syntax uses database facilities for "binding" the
parameter
	> values to the SQL statement, while the form you mention is
simply
	> altering the SQL statement that gets sent to the database.
There are
	> several benefits to using parameter binding:
	> 
	> 1)	you don't need to worry about escaping string values
	> 2)	certain types of values *can't* be specified in the SQL
	> statement (typically, LONG/BLOB/IMAGE.. whatever you want to
call it)
	> 3)	you can actually achieve higher efficiencies using
parameter
	> binding. The standard sequence of operations with a database
is: parse
	> the statement, bind parameters, execute the statement, fetch
the
	> results. With parameter binding, you can fill in values to the
bound
	> memory and re-execute the statement (skipping the parse/bind
steps). By
	> altering the SQL string, you have to go through all the steps
again. The
	> parse step is surprisingly expensive!
	> 
	> You will see the use of "?" in some database interfaces rather
than the
	> :N syntax (which comes from Oracle, actually). The :N variety
was chosen
	> because binding positionally is quite handy in a variety of
contexts.
	> 
	> I hope that clears things up!
	> 
	> -g
	> 
	> 	-----Original Message-----
	> 	From:	Daniel Larsson
[SMTP:Daniel.Larsson@vasteras.mail.telia.com]
	> 	Sent:	Thursday, April 17, 1997 1:17 PM
	> 	To:	python-list@cwi.nl
	> 	Subject:	Re: Looking for examples of oracledb
usage
	> 
	> 	 Anthony Baxter wrote in article
<199704150430.OAA01115@jambu.off.connect.com.au>...
	> 	>
	> 	>something like
	> 	>
	> 	>curs.execute("select * from db where blah = :1 and foo
= :2",(123,456))
	> 	>
	> 	>works for me.
	> 
	> 	In general, how does this differ from using the standard
string formatting, e.g.
	> 
	> 	curs.execute("select * from db where blah = %d and foo =
%d" % (123, 456))
	> 
	> 	(I assume these examples are equivalent, but I'm asking
for the general
	> 	case)
	> 
	> 	>>>> Roy Smith wrote
	> 	>> I'm looking for example of python code that uses the
oracledb module.
	> 	>> I've got simple stuff working, but havn't yet figured
out how to do
	> 	>> variable binding in an execute call.  The
documentation says, "Variables
	> 	>> are specified in a database-specific notation that is
based on the index
	> 	>> in the parameter tuple (position-based rather than
name-based)", but I'm
	> 	>> not quite sure what all that means.


_______________
DB-SIG  - SIG on Tabular Databases in Python

send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
_______________