[DB-SIG] Insert for Oracledb

Cary Collett caryc@shore.net
Fri, 21 Nov 1997 08:44:11 -0500 (EST)


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
_______________