In article <. com>, Paul Lalli wrote:
> On Jun 28, 10:15 am, Justin C <justin.0...@purestblue.com> wrote:
>> My program connects to a database, and is to insert a row into a table.
>> It runs with no errors or warnings but the database is not updated.
>> There is nothing in the Postgresql log either.
>>
>> Here is the code, it's a small as I can make it:
>>
>> #!/usr/bin/perl
>>
>> use warnings ;
>> use strict ;
>> use DBIx::Simple ;
>> use SQL::Abstract ;
>>
>> my $user = "[user]" ;
>> my $password = "[passwd]" ;
>> my $dataSource = DBIx::Simple->connect(
>> 'dbi
g:database=prospects', $user, $password,
>> { RaiseError => 1 , AutoCommit => 0 }
>
> You've turned off auto-commit, but never actually comitted your work.
> Either turn AutoCommit back on, or explicitly commit your data. I
> recommend a block similar to:
>
> END {
> if ($?) { # exiting with error
> $dataSource->rollback();
> } else { # success
> $dataSource->commit();
> }
> }
>
> Paul Lalli
Hello, again, Paul. I read a lot of documentation for Perl modules that
work with postgresql, so many that when I got to DBIx::Simple I may have
skimped, and skipped straight to the examples... That and I *always* get
confused by boolean 0/1 and which is which... mind you, I should have
been prompted by the RaiseError => 1. The situation isn't helped by the
fact that I've no SQL experience (learning as I'm going along) and I'm
no Perl expert either - but I know more than I do SQL.
Looking at your suggestion, I understand what you're suggesting, but I
don't fully understand your code... no, that's not true, I don't
understand: "END { "
Maybe I'm showing how green I really am. I can see you're testing for
errors, I understand the rollback, and commit. I can't find, in perldoc
-q or -f anything relating to an 'END'. Could you point me at some docs
to explain what is going on there? I know there is a need to trap out
errors if the database throws back an error, at the moment I'm trying to
get to a point of working code, the error trapping would come along
next, honest!
Thanks for the help with the problem.
Justin.
--
Justin C, by the sea.