Perl hashref and DBI

David A. Bandel david.bandel at gmail.com
Sun Mar 6 19:24:09 PST 2011


On Sun, Mar 6, 2011 at 22:08, Andrew Gould <andrewlylegould at gmail.com> wrote:
> On Sun, Mar 6, 2011 at 8:30 PM, David A. Bandel <david.bandel at gmail.com> wrote:
>> Folks,
>>
>> I have a database where I need to select a particular column as a Perl
>> hashref.  The column has data that looks like this:
>> SIP/100-00005ec8
>> SIP/100-00005ec9
>> SIP/119-00005cca
>> SIP/129-00005ec8
>>
>> I need to use this column as a key, but using either just the SIP/100
>> or preferably just the 100 part.  Ideally, I would just preprocess the
>> input to DBI's selectall_hashref, but not sure if that can be done.
>> Basically, SIP/100 is an extension, and I need to strip off (or mask)
>> the unique hex channel id so I can count() the number of calls
>> received by each extension.
>>
>> Thoughts on a way to do this anyone?
>>
>> TIA,
>>
>> David A. Bandel
>> --
>> Focus on the dream, not the competition.
>>             - Nemesis Air Racing Team motto
>> Visit my web page at: http://david.bandel.us/
>>
>
> Hi David,
>
> I don't use Perl, so I googled the keywords to try to understand what
> you were talking about, and found this:
> http://www.felixgers.de/teaching/perl/perl_DBI.html
>
> In the section titled, "Queries", the web page discusses the need to
> prepare queries.  It is in the prepare statement that the SQL
> statement is built.  Does your database have the functions needed to
> isolate the extension in the SQL query itself?  (Is this what you
> meant by "preprocess the input to DBI's selectall_hashref"?)  If so,
> then it would seem that the easiest solution depends on the database
> backend rather then Perl.  What database application/server is being
> used?

postgresql backend.  But the column contains data that would cause
each row to appear to be unique.  I need to make the values be
non-unique.   What I was hoping was if someone knew a way (documented
or not) to chomp off the characters from the hyphen to the end before
it was pushed into the hashref.

The SQL standard allows you to select or not a column, but not a
partial column.  Guess I'll end up grabbing the data from the db then
counting data matches based only on characters 5-7 of the query
result.

>
> Andrew
>

Thanx,

David A. Bandel
-- 
Focus on the dream, not the competition.
            - Nemesis Air Racing Team motto
Visit my web page at: http://david.bandel.us/




More information about the Linux-users mailing list