Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found