I jumped the gun on incorporating the new sequence code. In doing so I found I
had
to make a change, see below-
tempCursor =self._connection.cursor()
sqltablestr = """SELECT substring((SELECT substring(pg_get_expr(d.adbin,
d.adrelid)
for 128) FROM pg_attrdef d
WHERE d.adrelid = a.attrelid
AND d.adnum = a.attnum
AND a.atthasdef
) FROM 'nextval[^'']*''([^'']*)')
FROM pg_attribute a
LEFT JOIN pg_class c ON c.oid = a.attrelid
LEFT JOIN pg_attrdef d ON d.adrelid = a.attrelid AND d.adnum =
a.attnum AND a.atthasdef
LEFT JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE (c.relname = %(tbl)s) AND a.attname = %(pk)s
and n.nspname= %(sch)s
AND NOT a.attisdropped
AND a.attnum > 0
AND pg_get_expr(d.adbin, d.adrelid) LIKE 'nextval%%'"""
tempCursor.execute(sqltablestr,{'tbl':localTableName,'pk':cursor.KeyField,'sch':localSchemaName})
rs = tempCursor.fetchall()
print rs
#if rs is None:
#dabo.dbActivityLog.write("no data in getLastInsertID")
sqlWithseq_name="""select currval(%s) as curval"""
tempCursor.execute(sqlWithseq_name,(rs[0][0],))
rs = tempCursor.fetchall()
I use a different parameter style than in the original code because I find it
easier to follow.
The change was 'nextval%' to 'nextval%%'. In the original form the psycopg
parser thought
the % at the end of nextval was another parameter place holder.
--
Adrian Klaver
[EMAIL PROTECTED]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]