You cannot pass "currval('users_user_id_seq')" as a parameter value, you have to pass an integer value instead. I solved this problem in this way:
"INSERT INTO employees (employee_user_id, employee_id, employee_first_name, employee_last_name, employee_address, employee_city, employee_state, employee_zip, employee_extension) VALUES ( currval('users_user_id_seq'), %(employee_id)s, %(employee_first_name)s, %(employee_last_name)s, % (employee_address)s, %(employee_city)s, %(employee_state)s, % (employee_zip)s, %(employee_extension)s)" % {'employee_first_name': u'Jeff', 'employee_city': u'Olathe', 'employee_state': u'KS', 'employee_address': u'150', 'employee_id': 3L, 'employee_extension': u'1112', 'employee_user_id': nextval('users_user_id_seq'), 'employee_zip': u'66062', 'employee_last_name': u'Poller' } j Jeff Cook wrote: > Hi all, > > I want to use the return value of a CURRVAL call as the value of a > column in a row I'm inserting, to link together related records. I'm > using Pylons with SQLAlchemy and SQLSoup. SQLAlchemy spits back at me > a DataError because I'm trying to place CURRVAL in an integer field. > How do I get the thing to reference the integer instead of taking my > words as the literal field value? > > This is the error I receive from Pylons: > <class 'sqlalchemy.exc.DataError'>: (DataError) invalid input syntax > for integer: "CURRVAL('users_user_id_seq')" 'INSERT INTO employees > (employee_id, employee_user_id, employee_first_name, > employee_last_name, employee_address, employee_city, employee_state, > employee_zip, employee_extension) VALUES (%(employee_id)s, % > (employee_user_id)s, %(employee_first_name)s, %(employee_last_name)s, % > (employee_address)s, %(employee_city)s, %(employee_state)s, % > (employee_zip)s, %(employee_extension)s)' {'employee_first_name': > u'Jeff', 'employee_city': u'Olathe', 'employee_state': u'KS', > 'employee_address': u'150', 'employee_id': 3L, 'employee_extension': > u'1112', 'employee_user_id': 'CURRVAL(users_user_id_seq)', > 'employee_zip': u'66062', 'employee_last_name': u'Poller'} > > Thanks in advance. : ) > > Signed > Jeff > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---