in reply to Re^7: 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

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

Replies are listed 'Best First'.
Re^9: Using perl to parse a file and update values into a database
by marto (Cardinal) on Jul 14, 2015 at 09:56 UTC
Re^9: Using perl to parse a file and update values into a database
by poj (Abbot) on Jul 14, 2015 at 16:47 UTC

    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