Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turn Select Statement from SQL DB to Perl Hash (fast)

Status
Not open for further replies.

calvinsinger

Programmer
Oct 21, 2002
22
US
Hi,

I would appreciate some help on this.
Problem: Is there fast way I can take the output of a select statement (from several tables) and directly turn it into a Perl Hash ? I want to be able to define the format of the Hash, it cannot be just any simple hash, but a Nested Perl Hash.

I know one can use DBI and get some hash directly, but I also read that it is not recommended if good performance is desired. I also do not if I choose the Hash Format I desire.

I was wondering if the following method is possible. First I produce the desired XML using SQL Server Select Statement with FOR XML EXPLICIT. Execute a stored procedure, (from within Perl) containing this SQL statement using Perl DBI. Then I somehow transfer this XML to Perl (I do not know how to do that though). Next I use perl's XML::Simple Module to turn the XML into a Perl Hash. Thus I get a Perl Hash of my choosen format. If this method will be any faster, I am not sure. I Also would prefer not to have to first create an XML file and then make Perl read the XML file.

Thank you.
Calvin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top