> 
> 
> Yes. You're right that NAME_uc/NAME_lc and their *_hash 
> variants need to be cleared from the cache. May actually be 
> good to work the other way round... delete all cached 
> attributes except a specific set.

[Michael, I thought this might be interesting to you, if you haven't done
this already]

Here's what I've done, but it looks pretty ugly to me.  I would have thought
it would be simpler.  Cced dbi-dev as I thought others doing multiple result
sets might be interested in this.  Basically, I wanted to use dbih_inner(),
but it's unavailable as it's a DBI static function.  

    /* very ugly...definitely depends heavily on internal DBI magic... */
    /* need to clear out NAME_uc, NAME_lc & NAME_hash, etc when there is a
new result set */
    orv = (SV*)DBIc_MY_H(imp_sth);
    ohv = SvROK(orv) ? SvRV(orv) : orv;
    if ( (mg=mg_find(ohv,'P')) == NULL) {       /* hash tie magic       */
        /* maybe it's already an inner handle... */
        if (mg_find(ohv, '~') == NULL) {
            inner = 0;
            croak("Error: sth is not a dbi handle?  Can't clear result set
for more results!\n");
        }
        inner = orv; /* was already a DBI handle inner hash */
    }
    else {
        inner = mg->mg_obj;  /* inner hash of tie */
    }

    if (inner) {
        while ( (value = hv_iternextsv((HV*)SvRV(inner), &key, &keylen)) ) {
            if (strncmp(key, "NAME_", 5) == 0 ||
                  strncmp(key, "TYPE", 4) == 0 ||
                  strncmp(key, "PRECISION", 9) == 0 ||
                  strncmp(key, "SCALE", 5) == 0 ||
                  strncmp(key, "NULLABLE", 8) == 0
               ) {
                hv_delete((HV*)SvRV(inner), key, keylen, G_DISCARD);
            }
        }
    }


Jeff

> 
> On Tue, Mar 11, 2003 at 11:48:12AM -0500, Jeff Urlwin wrote:
> > FYI -- did you see this message on DBI-users?  I received a strange 
> > bounce message and I'm checking on it:
> > 
> > ---
> > 
> > I'm looking into it.  I clear out all the NAME attributes, 
> but must be 
> > missing the cache from the NAME_uc or NAME_lc.
> > 
> > Jeff
> > 
> > > 
> > > Jeff,
> > > 
> > > On your script, if you change the fetchrow_hashref to 
> > > fetchrow_hasref{'NAME_lc'} or fetchrow_hasref{'NAME_uc'} it fails 
> > > just like mine.
> > > 
> > > if you run with no argument or just NAME, it works fine.
> > > 
> > > Cheers.
> > > Iso
> > > 
> > > -----Original Message-----
> > > From: Jeff Urlwin [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, March 10, 2003 8:53 AM
> > > To: Ismail Mutlu; [EMAIL PROTECTED]
> > > Subject: RE: Multiple Select statements in an SP and 
> > > fetchrow_hashref
> > > 
> > > 
> > > Try the attached file and let me know how it runs.  Set 
> > > DBI_DSN,DBI_USER and DBI_PASS environment variables first.
> > > 
> > > If this doesn't produce good output, then:
> > >   a) upgrade your SQLServer driver (MDAC 2.7).  My SQL 
> Server driver 
> > > is 200.81.9030.04
> > >   b) compare this script to what you are doing and see if
> > > you can make mine break.
> > > 
> > > Jeff
> > > 
> > > > -----Original Message-----
> > > > From: Ismail Mutlu [mailto:[EMAIL PROTECTED]
> > > > Sent: Monday, March 10, 2003 11:23 AM
> > > > To: Jeff Urlwin; [EMAIL PROTECTED]
> > > > Subject: RE: Multiple Select statements in an SP and
> > > fetchrow_hashref
> > > > 
> > > > 
> > > > Jeff,
> > > > I have DBI 1.34 and DBD::ODBC 1.04 installed.
> > > > 
> > > > Thanks.
> > > > Iso
> > > > 
> > > > -----Original Message-----
> > > > From: Jeff Urlwin [mailto:[EMAIL PROTECTED]
> > > > Sent: Saturday, March 08, 2003 3:28 AM
> > > > To: Ismail Mutlu; [EMAIL PROTECTED]
> > > > Subject: RE: Multiple Select statements in an SP and
> > > fetchrow_hashref
> > > > 
> > > > 
> > > > > 
> > > > > Hello list,
> > > > > 
> > > > > I am using DBD::ODBC against SQL 2000 server. In my 
> script I am 
> > > > > executing a Stored Procedure which has two select statements 
> > > > > selecting from two different tables. I am looping through to 
> > > > > grep the output of the SP using fetchrow_hashref, each time I
> > > get a row I
> > > > > print the keys and the values of the hash. The  first hash 
> > > > > prints fine(with the column names from the first table) , but 
> > > > > the second one inherits the hash keys from the first one(the 
> > > > > values
> > > are correct
> > > > > tough). I tried 'undef'ing the hashref and the hash but
> > > still wont
> > > > > work. Here is my code:
> > > > > 
> > > > > 
> > > > 
> > > > What version of DBD::ODBC are you using?  If you are *not* using
> > > > 1.04 and DBI 1.32, stop and get them.  I believe these 
> issues have 
> > > > been found and fixed.
> > > > 
> > > > Regards,
> > > > 
> > > > Jeff
> > > > 
> > > > > 
> > > > > -------------------------------------CODE---------------------
> > > > > ------------------------------------------
> > > > > $sth1->execute();
> > > > > while ( $sth1->{Active}) {
> > > > >    do {
> > > > >       my $rowRef;
> > > > >       for (my $rowRef ;$rowRef=
> > > $sth1->fetchrow_hashref('NAME_lc');
> > > > > )  {
> > > > >           my %outputData = %$rowRef;      undef $rowRef;
> > > > >           print 'outputData ', Dumper(\%outputData), "\n";
> > > > >           undef %outputData;
> > > > >       }
> > > > >    } while ($sth1->{odbc_more_results});
> > > > > }
> > > > > --------------------------------------------------------------
> > > > > ------------------------------------------
> > > > > It gives me:
> > > > > 
> > > > > --------------------------------OUTPUT------------------------
> > > > > -----------------------------------
> > > > > outputData $VAR1 = {
> > > > >           'address' => 'My Address',
> > > > >           'acctnumber' => '321'
> > > > >         };
> > > > > 
> > > > > outputData $VAR1 = {
> > > > >           '' => 'iso       ',
> > > > >           'address' => '123',
> > > > >           'acctnumber' => '123'
> > > > >         };
> > > > > --------------------------------------------------------------
> > > > > ------------------------------------------
> > > > > Output for the first select is correct, but the second
> > > one shold be:
> > > > > outputData $VAR1 = {
> > > > >           'name' => 'iso       ',
> > > > >           'Number' => '123',
> > > > >           'acctnumber' => '123'
> > > > >         };
> > > > > 
> > > > > If I run the following, the out put is correct:
> > > > > -------------------------------------CODE---------------------
> > > > > ------------------------------------------
> > > > > $sth1->execute();
> > > > > while ( $sth1->{Active}) {
> > > > >    do {
> > > > >       my $rowRef;
> > > > >       while (my $p = $sth1->fetchrow_hashref()) {
> > > > >          print "new select \n";
> > > > >          while (my ($key, $value) = each %$p) {
> > > > >          print "\t $key : $value\n";
> > > > >     }
> > > > >     print "\n\n";
> > > > >    } while ($sth1->{odbc_more_results});
> > > > > }
> > > > > ------------------------------------------------------------
> > > > > 
> > > > > 
> > > > > Any Ideas,
> > > > > 
> > > > > Cheers!.
> > > > > Iso
> > > > > _______________________________________________
> > > > > Perl-Win32-Database mailing list 
> > > > > [EMAIL PROTECTED]
> > > > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> > > > > 
> > > > 
> > > > 
> > > > 
> > > 
> > > 
> > > 
> > 
> > 
> > 
> > 
> 


Reply via email to