{"id":47,"date":"2004-03-01T11:50:05","date_gmt":"2004-03-01T15:50:05","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/rlucastemp\/2004\/03\/01\/fix-cant-locate-object-method-sele"},"modified":"2004-03-01T11:50:05","modified_gmt":"2004-03-01T15:50:05","slug":"fix-cant-locate-object-method-select_val-via-package-dbist-under-cl","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/2004\/03\/01\/fix-cant-locate-object-method-select_val-via-package-dbist-under-cl\/","title":{"rendered":"FIX: Can&#8217;t locate object method &#8220;select_val&#8221; via package &#8220;DBI::st&#8221; under Class::DBI 0.95"},"content":{"rendered":"<p><a name='a29'><\/a><\/p>\n<p><P><STRONG>[warning: see updates below]<\/STRONG><\/P><br \/>\n<P>Between Class::DBI 0.94 and 0.95, something changed causing my classes that override db_Main() to set the db connection (instead of, e.g. using set_db) to stop working.&nbsp; Specifically, when their sequence functions were invoked, I got an error of:<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>Can&#8217;t locate object method &#8220;select_val&#8221; via package &#8220;DBI::st&#8221; (perhaps you forgot to load &#8220;DBI::st&#8221;?) at \/usr\/lib\/perl5\/site_perl\/5.6.1\/Class\/DBI.pm line &#8230;<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>I was able to replicate this on Mac OS X 10.2 with Perl 5.6.0 and Red Hat 9 with 5.6.1 (don&#8217;t ask about the latter version magic&#8230;).<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>If you get select_val errors with Class::DBI 0.95, here are two workarounds:<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<UL><br \/>\n<LI>downgrade to 0.94, found here: <A href=\"http:\/\/search.cpan.org\/CPAN\/authors\/id\/T\/TM\/TMTM\/Class-DBI-0.94.tar.gz\">http:\/\/search.cpan.org\/CPAN\/authors\/id\/T\/TM\/TMTM\/Class-DBI-0.94.tar.gz<\/A><br \/>\n<LI>make sure you use set_db instead of db_Main to set the db connection<\/LI><\/UL><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>I am not sure why this is (comments are welcome) and have submitted a bug to the developers as CPAN #5522.<\/P><br \/>\n<P><STRONG>Update:<\/STRONG> Thanks to Tony Bowden, maintainer of Class::DBI, for his reply:<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<BLOCKQUOTE><br \/>\n<P>Full context and any attached attachments can be found at:<BR>http:\/\/rt.cpan.org\/NoAuth\/Bug.html?id=5522<\/A> &gt;<\/P><br \/>\n<P>On Mon, Mar 01, 2004 at 06:42:38PM -0500, Guest via RT wrote:<BR>&gt; In Class::DBI 0.95, setting up the DB connection by overriding db_Main<BR>&gt; breaks Ima::DBI-&gt;select_val and the methods that rely on it (like sequence<BR>&gt; and count_all)<\/P><br \/>\n<P>You need to call Ima::DBI-&gt;connect rather than DBI-&gt;connect in your<BR>overriden db_Main.<\/P><br \/>\n<P>Tony<\/P><\/BLOCKQUOTE><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>Still not certain, though, <EM>why<\/EM> it is that it breaks in 0.95 and not 0.94.<\/P><br \/>\n<P><STRONG>Update<\/STRONG>: Thanks again to Tony, who writes:<\/P><br \/>\n<BLOCKQUOTE><br \/>\n<P>The reason this broke in going from 0.94 to 0.95, btw, is that the<BR>select_val stuff was only added to Ima::DBI recently, so Class::DBI .94<BR>didn&#8217;t use these, but instead rolled its own long winded versions.<\/P><br \/>\n<P>0.95 uses the new methods in Ima::DBI and is a lot better off for it! \ud83d\ude42<\/P><br \/>\n<P>Tony<\/P><\/BLOCKQUOTE><br \/>\n<P dir=\"ltr\"><STRONG>Update 23 April 2004<\/STRONG>: Things are all wacky now.&nbsp; You should be careful and should probably NOT do any of the above.&nbsp; See the 06 April 2004 exchanges on the CDBI mailing list.&nbsp; If you do what is described above you stand to get reconnections that will mess up things like auto_increments in MySQL.&nbsp; At present the issue of how to deal with db_Main() seems unresolved.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[warning: see updates below] Between Class::DBI 0.94 and 0.95, something changed causing my classes that override db_Main() to set the db connection (instead of, e.g. using set_db) to stop working.&nbsp; Specifically, when their sequence functions were invoked, I got an error of: &nbsp; Can&#8217;t locate object method &#8220;select_val&#8221; via package &#8220;DBI::st&#8221; (perhaps you forgot to [&hellip;]<\/p>\n","protected":false},"author":1180,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1460],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-rlucasstories"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/users\/1180"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":0,"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/rlucastemp\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}