in reply to Re^6: Using perl to parse a file and update values into a database
in thread Using perl to parse a file and update values into a database

"still not working" isn't something we can help you with, but you know that already. How do I post a question effectively?. Tutorials->Debugging and Optimization->Basic debugging checklist.

  • Comment on Re^7: Using perl to parse a file and update values into a database

Replies are listed 'Best First'.
Re^8: Using perl to parse a file and update values into a database
by bhushanQA (Sexton) on Jul 14, 2015 at 09:40 UTC
    Yes.. I need the help in this.. question is pretty clear or not ?? This code is not working at all:
    sub read_initial_data { my $config = Config::Tiny->read('/home/database_update.txt'); foreach my $section (sort keys %$config) { print "[$section]\n"; foreach my $parameter ( keys %{$config->{$section}}) { $parameter = $config->{$section}->{$parameter} +; my $sth = $dbh->prepare(qq{update $section set + Account_balance=20000 where Id = 101}); $sth->execute(); $sth->finish(); print"$parameter\n"; } } }
    database_update.txt having
    [Subscriber] Id=101 Account_balance=2000000
    Here I am hard coding the 'set' and 'where' parameters... I don't want to hard code those thing.. I have used '?' its is not working.. please help me on this

      As far as I understand, the first config element in each section is the identifying key for the update. For example UPDATE .... WHERE id=101. Since you cannot determine the parameter order using  keys %{$config->{$section}}, how will this work predictably ?

      Other questions are
      1.. Are there updates to many records in a table ?. In other words, does the [Subcriber] section appear many times in the text file ?.
      2.. Is the order in which the updates are applied important ?

      poj