Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

modifying fetchall_arrayref({}) result

by Michalis (Pilgrim)
on Sep 13, 2005 at 19:05 UTC ( [id://491661]=perlquestion: print w/replies, xml ) Need Help??

Michalis has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I thought I'ld ask just in case someone has a bright idea (as usual :))
I execute a select statement against a database table, and retrieve all the data with fetchall_arrayref({}).
All is working ok, but once in a while I need to slightly modify some data as it comes from the database. For example, if I have a datetime field, I usually reformat it to Greek date formating.
Does anybody know if there is any way to do that?

Thanks in advance
-- Michalis

Replies are listed 'Best First'.
Re: modifying fetchall_arrayref({}) result
by jZed (Prior) on Sep 13, 2005 at 19:10 UTC
    Depending on your DBMS, you may be able to do that directly in the SQL. If not, then simply prepare, execute, and fetch the statement in a loop and process the rows during the loop.
      A! so simple if you think of it.
      You are absolutely correct, I'll do it in the database.
      Thank you for the answer....
      -- Michalis
Re: modifying fetchall_arrayref({}) result
by saberworks (Curate) on Sep 13, 2005 at 21:15 UTC
    You could create a YourDBI module which inherits from DBI and override only the method you care about. I think doing it in the database is better but this is an alternate solution in case your db doesn't allow that.
Re: modifying fetchall_arrayref({}) result
by dragonchild (Archbishop) on Sep 13, 2005 at 20:45 UTC
    If you're willing to work with Class::DBI, you can specify that this column needs to be passed into some object, like DateTime, that would then do what you wanted it to do.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://491661]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-28 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found