No such thing as a small change | |
PerlMonks |
Class::DBI && Sybaseby kal (Hermit) |
on Apr 03, 2003 at 13:39 UTC ( [id://247751]=perlquestion: print w/replies, xml ) | Need Help?? |
kal has asked for the wisdom of the Perl Monks concerning the following question: Hi guys. I'm having wonderful fun implementing 'latest app' in Class::DBI and Class::DBI::Pager (I've put off learning these modules for a while, and now regret it ;). However, I do have a problem - I'm interfacing with a Sybase database setup with auto incrementing (IDENTITY) primary keys, and Class::DBI doesn't like them. Looking at the code, there is already a bit of a hack in there for this:
Now, sadly, I can't just hook in there, because on Sybase I need to execute 'SELECT @@identity' immediately after the INSERT, there's no convenient variable hanging around for me to poach. And herein lies the issue. I've overridden _auto_increment_value() to do this extra query, but all I get back is '0'. It seems that by the time I get to execute my query, Sybase has forgotton what @@identity is. I'm assuming this is to do with the database handle - I've tried turning off autoupdate/autocommit, but that doesn't make any different. I guess I'm just not getting their in time. I've even tried overriding _insert_row(), still no go. Perhaps the answer lies in Ima::DBI somewhere. Has anyone got this combination to work in this style? I don't personally want to run without auto-incrementing keys, because that would be work. However, I do need to find some way of getting back the id of the recently created object, otherwise Class::DBI isn't going to speak to me :/ Can anyone offer any hints?
Back to
Seekers of Perl Wisdom
|
|