I am trying to set up an object with the aid of Class::DBI (actually Class::DBI::Sybase) All classes have been set up according to the documentation and I wrote a quick program to verify C::D behavior. The original test program ran retrieve_all() which was successful. However when I run a search() based on the PK an error is returned "sth_to_objects needs a statement handle".

Looking under the hood we find that indeed $sth is not valued, but oddly enough when sth_to_objects() is called (from within C::D itself) $sth is not even passed.

Obviously it must be something that I am doing wrong if there is plenty documentation on how to use the module, but nothing on the strange behavior experience by this humble monk.

Any advice?

Code and results...

The base class...

package user::user; use base 'Class::DBI::Sybase'; user::user->set_db('Main', 'DBI:Sybase:database=YYYYYY;server=127.0.0. +1;textsize=4550', 'xxxxxxxx', 'xxxxxxxx'); __PACKAGE__->table('users'); __PACKAGE__->columns(All => 'recnum', 'firstname', 'lastname', 'email' +); 1;
The test program
#!/usr/bin/perl -w use strict; use user::user; use Data::Dumper; my @cols = user::user->columns; print "COLUMNS:\n"; print "$_\n" foreach @cols; print "\n\nAnd now the table data...\n"; my @obj = user::user->search(recnum =>1); print "$_\n" foreach @obj;
The results
COLUMNS: lastname firstname email recnum And now the table data... sth_to_objects needs a statement handle at ./cdbi_tst.pl line 38

Thanks in advance


In reply to Clarification on Class::DBI wackiness by spork

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.