Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi,

I'm building a 'thread safe' class to running dbcc on MS SQL servers and translate the result on something readable and storeable. I got a example on DBD::ODBC package about how can I handle the DBCC message and his example is working well on a single program, but I still in trouble where talk about my class.

On code bellow, is a sample of how I'd like to get my class working, but I couldn't get the handle error as i want.

I have no more idea about how solve this problem. Maybe have no solution, or someone here can.

Thanks to much,

my $ODBC = DBCCMessage->new(); $ODBC->open ( qq{dbi:ODBC:driver={SQL Server};Server=127.0.0.1;databas +e=Northwind;Truted Connection=yes} ); my %s_ADO = $ODBC->get_index_fragmentation(); package DBCCMessage; use Class::Std; use Class::Std::Utils; { use DBI; use strict; my %dbConnection : ATTR; my %recordSet : ATTR; my %objError : ATTR; sub BUILD { my ( $self, $ident, $startString ) = @_; if ( $startString ) { my ( $stringConnection ) = map { $startString->{$_} if ( $_ =~ /conne +ction/i ) } keys %{$startString}; $self->open( $stringConnection ) if ( $stringConnection ); } } sub open { my ( $self, $conString ) = @_; $dbConnection{ident $self} = DBI->connect ( $conString, qq{}, qq{} ) or die qq{Can't connect to dat +abase, erro : $DBI::errstr}; } sub err_handler { my ( $self, $state, $msg, $nativeerr ) = @_; $msg =~ s/^(\[[\w\s:]*\])+//; push @{$objError{ident $self}}, $msg; return 0; } sub get_index_fragmentation { my $self = shift; my %return; my $ident = ident $self; my $sth = $dbConnection{$ident}->prepare(q{DBCC SHOWCONTIG (215751 +15, 1)}); $dbConnection{$ident}->{odbc_err_handler} = \&{$self->err_handler( +)}; $dbConnection{$ident}->{odbc_async_exec} = 1; $sth->execute(); } } 1;
Solli Moreira Honorio
Sao Paulo - Brazil

In reply to Handling DBD::OBDC error on a 'thread safe' class by shonorio

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: (3)
As of 2024-04-16 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found