Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    105

    Unanswered: Sql Insert of a Hash of a hash

    I am having trouble doing a sql insert for a hash of a hash. I don't know how to reference the hashes to access the content that I need.

    I received help two days ago with an sql statement but now my needs have changed because I needed a hash of a hash instead of a single hash.

    I have a hash of a hash:

    my %HoH = (
    Host =>{
    hw_SerialNumber => "7RW2R31"
    },
    CPU => {
    hw_TotalPhysicalMemory => "1072693248"
    }
    );

    foreach my $table(keys %HoH){
    foreach my $field (keys %{$HoH{$table}}){
    #need to do my insertion here with $table being the Table in which to put the data in and $field is the name of the field names.
    }
    }
    Any Ideas?

    Thanks,
    Laura

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    I've posted my idea here: http://www.dbforums.com/t1006451.html
    board.perl-community.de - The German Perl-Community

  3. #3
    Join Date
    May 2004
    Posts
    105
    raneeb,

    Thanks for your help I have been using this piece of code to populate my database but I am having one problem with perl basics, maybe you can answer this faster than me searching for it.

    my $statement = 'INSERT INTO '.join(', ',@tableName).' ('.join(', ',@sorted).') VALUES ('.join(', ',@values).')

    on the last part after values how do I get each value to be enclosed in ' ' ?
    Is there a way to append these?

    Thanks,
    Laura

  4. #4
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    my $statement = 'INSERT INTO '.join(', ',@tableName).' ('.join(', ',@sorted).') VALUES ('.join(', ',map{"'".$_."'"}@values).')';
    board.perl-community.de - The German Perl-Community

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •