Hi All! I use postgresql and I have to emulate partial sequence (sequence with predicate).
I have transactions table with "serial_id" field - this field have to be autoincrement field and unique for "commit_date" and "user_office_id". When I perform an insert to this table I have to do something like that in SQL: BEGIN; LOCK transactions IN ROW SHARE MODE; SELECT serial_id FROM transactions WHERE FOR UPDATE; MAX_SERIAL_ID = SELECT MAX(serial_id) FROM transactions WHERE commit_date=CURRENT_TIMESTAMP AND user_office_id=93; INSERT INTO transactions VALUES (MAX_SERIAL_ID+1, 93, 'other data1'), (MAX_SERIAL_ID+1, 93, 'other data2'), (MAX_SERIAL_ID+1, 93, 'other data3'); COMMIT; --OR-- last_serial = execute(select([func.max(transactions.c.serial)], transactions.c.user_office_id==93, transactions.c.commit_date==datetime.date.today())).fetchone()[0] AND then execute(transactions_table.insert(), [{93, last_serial+1, 'other', 'data'}, ...]) How to do that to not allow other insert's to be executed between my select and insert statements from other requests and I don't want to block select statements to transactions table!? Is there any "magic" in SA to do that or may be I choose wrong way to do that kind of stuff? Help me please I'm stucked with that :( Thanks a lot! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---