[DB-SIG] Insert for Oracledb

Michael Lorton mlorton@microsoft.com
Fri, 21 Nov 1997 08:30:07 -0800


The Right Way:
>>> qs = "INSERT INTO ppiOrder
(orderID,accountID,amount,discountPercent,salesRepName) VALUES (:1, :2, :3,
:4)"
>>> cu.execute(qs, a)

If you want to experiment with the way Cary and others suggested (i.e.,
physically pasting the text into the query), consider inserting a work with
a single quote ("It won't work" :-)

M.

> -----Original Message-----
> From:	Cary Collett [SMTP:caryc@shore.net]
> Sent:	Friday, November 21, 1997 5:44 AM
> To:	white@fnal.gov
> Cc:	db-sig@python.org
> Subject:	Re: [DB-SIG] Insert for Oracledb
> 
> 
> Vicky,
> 
> Here's a quick, dirty example...
> 
> >>> import oracledb
> >>> cobj = oracledb.oracledb('foo/bar')
> >>> cu = cobj.cursor()
> >>> a = (1,11714,10,0,'Bob')
> >>> qs = "INSERT INTO ppiOrder
> (orderID,accountID,amount,discountPercent,salesRepName) VALUES (" +
> str(a[0]) + "," + str(a[1]) + "," + str(a[2]) + "," + str(a[3]) + ",'" +
> a[4] + "')"
> >>> qs
> "INSERT INTO ppiOrder
> (orderID,accountID,amount,discountPercent,salesRepName) VALUES
> (1,11714,10,0,'Bob')"
> >>> cu.execute(qs)
> 1
> >>> cobj.rollback()    
> 
> 
> You might also have your program send the query string to the stdout 
> or stderr to see what it looks like. Try it in sqlplus, it will
> give you a little bit better error diagnostics.
> 
> 
> 
> Hope this helps,
> 
> Cary
> 
> > 
> > Please can someone send me a working code sample of how they
> > successfully used the oracledb module (from Digital Creations) to insert
> > one or more rows into an oracle database, preferably based on a List of
> > previously constructed Tuples.
> > I have looked at the example posted by Andrew Kuchling (for Solid), and
> > read most of the past email, including a discussion about binding of
> > variables using the :N notation.  However, although I can query the
> > database I have had no success at inserting rows, except by hardcoding
> > the values into the sql string.
> > Whatever I try I seem to get Parse errors, or too many arguments, or
> > sql  not properly terminated, or missing parens, or something! - even
> > for 1 row.
> > There seems to be very little activity on this SIG, with no updates to
> > database API documentation since 1996!   Is there really no-one out
> > there using this stuff, for Oracle?
> > Would appreciate help
> >                                     Vicky White
> > 
> > 
> > _______________
> > DB-SIG  - SIG on Tabular Databases in Python
> > 
> > send messages to: db-sig@python.org
> > administrivia to: db-sig-request@python.org
> > _______________
> > 
> 
> 
> _______________
> DB-SIG  - SIG on Tabular Databases in Python
> 
> send messages to: db-sig@python.org
> administrivia to: db-sig-request@python.org
> _______________

_______________
DB-SIG  - SIG on Tabular Databases in Python

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