I've read the DBI documentation and I've searched the DBI-users archive.  I 
found the selectrow_arrayref and selectrow_hashref commands to be almost exactly what 
I'm looking for.  The issue is that I would like to bind a sql data type to one or 
more of the placeholders.  At the moment, I'm using something that looks like this:

        $SQL = qq{SELECT col1, col2, col3 FROM mytable WHERE col1=? AND col2=?};

        $sth = $dbh->prepare_cached($SQL);
        if($dbh->err) 
        { 
                handle error;
        }
        $sth->bind_param(1, $col1_val, SQL_INTEGER);
        $sth->bind_param(2, $col2_val, SQL_VARCHAR);

      $data = $dbh->selectall_arrayref($sth);
      if($dbh->err)
      {
          handle error;
      }

      if(@$data)
        {
                work with data;
        }


        Looking at the documentation for selectrow_arrayref and selectrow_hashref, it 
seems that I could provide the data types and the binding in one call.  The problem is 
that I can't find anything in the documentation for how to format and what to put in 
the %attr value.  I would like to write my DBI calls like this:

        $SQL = qq{SELECT col1, col2, col3 FROM mytable WHERE col1=? AND col2=?};

        $sth = $dbh->prepare_cached($SQL);
        if($dbh->err) 
        { 
                handle error;
        }

        %attr = (??????);     # don't know what to put here 
      $data = $dbh->selectall_arrayref($sth, \%attr, $col1_val1, $col2_val);
      if($dbh->err)
      {
          handle error;
      }

      if(@$data)
        {
                work with data;
        }        



Nelson Arzola
--
Nelson Arzola                                  
Unix Systems Administrator
Voice: 206.252.0471

  "The most likely way for the world to be destroyed, most experts agree, is 
   by accident. That's where we come in; we're computer professionals. We 
   cause accidents."
            -- Nathaniel Borenstein

Reply via email to